AppendChunk
Hi,
I am using VB6 & Oracle 8i.
I am trying to update a CLOB field (more than 4000 characters).
strConnectionString = "Provider=MSDAORA.1;User ID= User; password = password;Data Source = Test;Persist Security Info=False"
CursorLocation = adUseClient
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command
Set rs = New ADODB.Recordset
Set cmd = New ADODB.Command
cmd.ActiveConnection = cnn1
cmd.CommandText = "select CLOBfield From table1 where ID=1"
Set rs = New ADODB.Recordset
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Open cmd
rs!CLOBfield.appenchunk(MoreThan4000CharString)
rs.update
I get the errormessage :
Operation not allowed in this context.
(I get this error even with varchar2 fields).
I tried to this through a stored procedure, but do not know
how to pass a CLOB to it.(I saw sample for BLOBs - but not for Clobs).
Many Thanks,
Does the Microsoft OLE DB to ODBC provider support LOB's? I know the Microsoft ODBC driver for Oracle doesn't. Which ODBC driver are you using?
I'd highly recommend using the Oracle OLE DB provider here.
Justin
Similar Messages
-
Problems writing BLOB data into O8i (ADO and AppendChunk)
We have a table where you want to store bianry data (BLOBs). I
have used the LONG RAW datatype to store this information. Here
is the code for the table:
CREATE TABLE "CONTENTBLOBTABLE" (
DIGEST NVARCHAR2(40) NOT NULL,
BLOB LONG RAW,
CHECK (DIGEST IS NOT NULL),
PRIMARY KEY (DIGEST)
Then we try to update this table with ADO 2.6 on a Windows 200
machine with Oracle ODBC driver. Here is the relevant code
snippet:
// set the value of the field
pRs->AddNew();
pRs->Fields->GetItem("DIGEST")->PutValue(strDigest);
pRs->Fields->GetItem("BLOB")->AppendChunk(varBLOB);
if(!pRs->Update())
C_LOG_CRITICAL(L"CC_CS_DAL::WriteBLOB - pRs->Update failed");
*error = C_CS_CBT_ERROR;
pRs->CancelUpdate();
pRs->Close();
m_pConn->Close();
m_spObjectContext->SetAbort();
return S_FALSE;
OK, NO error occurs: no exception, HRESULT return values are all
OK, method completes.
BUT: there is no data in the table!?!?! When querying the exact
same table we get an empty result!
Any ideas please?
Thanks,
ChristianDid you even get a reply to this message?
-
How could I use Appendchunk Function in DBTools
I am a user of Labview2009,I want save a binary file into MySQL(5.1) and I want use the Appendchunk Function ,which is one method of the ADO-parameter object . How should I do it with LabView DBTools?
thanks your help!
charlesHave you tried looking in the Database Connectivity Toolkit documentation yet? I've implemented sending all kinds of data to a SQL database with its help. You can find it at:
http://digital.ni.com/manuals.nsf/websearch/F0E03761C7F4ACB486256A3E00509BA9?OpenDocument
I'm not aware of how to use the Appendchunk function in LabVIEW. I'm not sure what will be the best way to store your data. You send/receive data with this toolkit using variants, but you might have to tell the database you are sending up a string. So unless you can send up the file, you'll need to open up the file and send its contens up as a string. If I'm wrong about that is there someone that knows how to send up a file to a DB with this toolkit?
Hope that helps! -
Oracle Rdb Driver 3.1.0.0 problem with blobs
I am trying to convert an MsAccess application to use an MsAccess front end and an Oracle Rdb back end.
I've created the test database under VMS and can successfully link to the Oracle Rdb tables from MSAccess 2000. One of the main reasons for converting to Oracle Rdb is to be able to store large word documents in the database. I was able to do that using Oracle rdb Driver v 3.00.02.06. I recently converted to Oracle Rdb Driver version 3.1.0.0 and can no longer access the Blob field containing the Word document. MsAccess now sees this field as type Binary and I keep getting an invalid field type error. (with 3.00.02.06 this field was seen by MsAccess as an Ole Object and the getchunk and appendchunk functions for getting and saving a blob worked reasonably well).
Is this a bug in 3.1.0.0 or is there some way to get MsAccess to recognize this Binary field type?I suspect you'll need to contact Oracle support on this. There aren't, to my knowledge, any RDB folks around here.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Hi,
I am calling a stored procedure with CLOB parameter and I need to pass NULL value to CLOB paramter through ADO in VC++.
My problem is when I send CLOB value as NULL a single Digit Binary value is inserted.I am using SAFEARRAY and AppendChunk mechanism to create CommandParameters for Storedprocedure.
Any suggestion where i am going wrong...
SDGI've never worked with CLOB's before. But, I've put a great deal of effort into trying to pass a null value to Oracle from ADO. Finally, I just gave up and simply specified other fields but not the one I wanted to be null. The end result is that the field contains null after the row is inserted. I realize you'd like a better answer, but, I thought I'd throw in my $0.02 anyhow.
Good luck. -
Oracle Rdb Driver 3.1.0.0 problem
I am trying to convert an MsAccess application to use an MsAccess front end and an Oracle Rdb back end.
I've created the test database under VMS and can successfully link to the Oracle Rdb tables from MSAccess 2000. One of the main reasons for converting to Oracle Rdb is to be able to store large word documents in the database. I was able to do that using Oracle rdb Driver v 3.00.02.06. I recently converted to Oracle Rdb Driver version 3.1.0.0 and can no longer access the Blob field containing the Word document. MsAccess now sees this field as type Binary and I keep getting an invalid field type error. (with 3.00.02.06 this field was seen by MsAccess as an Ole Object and the getchunk and appendchunk functions for getting and saving a blob worked reasonably well).
Is this a bug in 3.1.0.0 or is there some way to get MsAccess to recognize this Binary field type?I suspect you'll need to contact Oracle support on this. There aren't, to my knowledge, any RDB folks around here.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
IDOC - XI - post HTTP on .ASP?& DATA_CONTENT
HI ALL !
I have this scenario :
1) R3 send IDOC ORDERS01 to XI (3.0)
2) XI elabs IDOC fields (in mapping step)
3) XI with HTTP Adapter post data to a "page".asp on webserver using querystring (like page.asp?&ID_CUSTOMER=123&ORD_DOC=WE ...etc..)
My ASP page use this stantments for get values:
ID_CUSTOMER = Request.Form("ID_CUSTOMER");
ORD_DOC = Request.Form("ORD_DOC");
xml_content = Request.Form("xml_content");
At the moment XI call the page but the query string is empty ! I think that the message type of interface will be automatically added on URL (as when flags Additional Query on Comm.Channel - Sender Party, Sender Service... are selected).... it's wrong ?!? If yes how it's possible complete the flow ?!
Thks !!Hi Jari,
Thanks for the reply,
I have the asp file as below and plz suggest for any changes,
<%
Function BinToText(varBinData, intDataSizeInBytes)
Const adFldLong = 128 '&H00000080
Const adVarChar = 129
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Fields.Append "txt", adVarChar, intDataSizeInBytes, adFldLong
objRS.Open
objRS.AddNew
objRS.Fields("txt").AppendChunk varBinData
BinToText = objRS("txt").Value
objRS.Close
Set objRS = Nothing
End Function
server.scripttimeout = 600
dim binXML, strXML, outXML, objFundsDelete
'if Request.TotalBytes > 0 then
' binXML=Request.BinaryRead(Request.TotalBytes)
' strXML=BinToText(binXML,lenb(binXML))
'else
' strXML=""
'end if
strxml = Request("xmlData")
'Response.ContentType="TEXT/XML"
'Response.Write(strXML)
'dim fs, LogFile
'logFile = "c:\received.xml"
'set fs = server.CreateObject("Scripting.FilesystemObject")
'on error resume next
'if fs.FileExists(LogFile) = false then
' set ts = fs.CreateTextFile(LogFile)
'end if
'set ts = fs.OpenTextFile(LogFile,2)
'ts.writeline strXML
'ts.close
'set fs = nothing
'set ts = nothing
set objFundsDelete=server.CreateObject("FundsDelete.CFundsTransfer")
outXML=objFundsDelete.FundsProcess(strXML)
set objFundsDelete=nothing
Response.ContentType="TEXT/XML"
Response.Write(outXML)
%>
Thanks,
srini -
Hi .
when i create a BLOB column in the table and describe the structure it says undefined. how do i fix that. also if someone can let me know how to update a RTF content from a VB to the BLOB column in the oracle table?? Tons of thanks in advanceYou can write a BLOB- VB to Oracle database using ADO function in VB. Search in MSDN for help on BLOB function. They have a ready eg.
Just in case you don't find it.
Here it is:
Just copy paste this in a form with text boxes for all ODBC parameters.
I think you cannot read directly from a BLOB column. Don't forget to initiate a BLOB column like:
/*LOB table for storing files*/
Drop table FileColumn;
Create table FileColumn
( REPQUE_ID NUMBER(10) NOT NULL ,
RepText_blob BLOB default empty_blob()
Storage (initial 50K next 50K pctincrease 0)
tablespace TEST31ORA
lob(RepText_blob) store as
(tablespace ACCOUNT4
Storage (initial 100k next 100k pctincrease 0)
chunk 16k pctversion 10 nocache logging);
/*initialize LOB locator by making it not null, use empty lob, this will
insert the locator value in that column
I did this initialize in create table script, so that I can do the bulk insert
One can do bulk inserts if there are no rows before
insert into FileColumn
values(1, empty_blob()); */
Option Explicit
Const BlockSize = 32768
' FUNCTION: ReadBLOB()
' PURPOSE:
' Reads a BLOB from a disk file and stores the contents in the
' specified table and field.
' PREREQUISITES:
' The specified table with the OLE object field to contain the
' binary data must be opened in Visual Basic code (Access Basic
' code in Microsoft Access 2.0 and earlier) and the correct record
' navigated to prior to calling the ReadBLOB() function.
' ARGUMENTS:
' Source - The path and filename of the binary information
' to be read and stored.
' T - The table object to store the data in.
' Field - The OLE object field in table T to store the data in.
' RETURN:
' The number of bytes read from the Source file.
Function ReadBLOB(Source As String, T As Recordset, _
sField As String)
Dim NumBlocks As Integer, SourceFile As Integer, i As Integer
Dim FileLength As Long, LeftOver As Long
Dim FileData As String
Dim RetVal As Variant
On Error GoTo Err_ReadBLOB
' Open the source file.
SourceFile = FreeFile
Source = "c:\blob_file_folder\G63JR557.doc"
T = mwebRepOutput
sField = RepOut_Content
Open Source For Binary Access Read As SourceFile
' Get the length of the file.
FileLength = LOF(SourceFile)
If FileLength = 0 Then
ReadBLOB = 0
Exit Function
End If
' Calculate the number of blocks to read and leftover bytes.
NumBlocks = FileLength \ BlockSize
LeftOver = FileLength Mod BlockSize
' SysCmd is used to manipulate status bar meter.
RetVal = SysCmd(acSysCmdInitMeter, "Reading BLOB", _
FileLength \ 1000)
' Put first record in edit mode.
T.MoveFirst
T.Edit
' Read the leftover data, writing it to the table.
FileData = String$(LeftOver, 32)
Get SourceFile, , FileData
T(sField).AppendChunk (FileData)
RetVal = SysCmd(acSysCmdUpdateMeter, LeftOver / 1000)
' Read the remaining blocks of data, writing them to the table.
FileData = String$(BlockSize, 32)
For i = 1 To NumBlocks
Get SourceFile, , FileData
T(sField).AppendChunk (FileData)
RetVal = SysCmd(acSysCmdUpdateMeter, BlockSize * i / 1000)
Next i
' Update the record and terminate function.
T.Update
RetVal = SysCmd(acSysCmdRemoveMeter)
Close SourceFile
ReadBLOB = FileLength
Exit Function
Err_ReadBLOB:
ReadBLOB = -Err
Exit Function
End Function
null -
How can I pass a BLOB parameter 32K from VB to a stored procedure?
I am using Visual Basic 6 and the Oracle database 10g to call stored procedures. I am passing a XML input parameter to this stored proc. This variable has been defined as BLOB in stored proc and as XMLType in the table to which it finally gets stored through procedure.
But there seems to be a limit to the size of a parameter you can pass in. This seems to be 32K!!! It works fine as long as my input is < 32k but once it becomes > 32k, Oracle gives the following error:-
"ORA-01460: unimplemented or unreasonable conversion requested"
I searched on net and found lots of examples for a workaround with .Net (using OracleLob). For Vb6, the only examples I found were using AppendChunk method etc through a loop, where each call will insert 32k chunk. But, that would mean lots of calls to stored proc, as we need to do this for thousands of files and each file of size > 100k.. So, this method would not be acceptable.
Can someone please help me with this.Mofizur,
You can achieve the same using Session variable.
If u are not executing the VO after PR. Then you will be able to get the same value as u are using in PR
String transactionId = (String) vo_trans.first().getAttribute("Getnexttrans");
Note - You have a few of the threads left open, mark it as answered if solved.
Regards,
Gyan -
Stored Procedure w/ binary data parameter problems in Visual Basic
Howdy all.
I am having a problem calling stored procedures with a BLOB parameter. I have tried changing the paramater other data types to see if it would work, but with no success. I am calling the stored procedure from Visual Basic using ADO. I am using the Oracle ODBC Driver, Release 9.2.0.4.0. I have tried changing the setup of the ODBC a good bit because that has fixed several problems for me in the past; however, it did not fix my current problem.
Here is what I am trying to do. I have a function like the folowing:
<BEGIN --------------------------------------->
CREATE OR REPLACE FUNCTION PAGEFORMATSINSERT(
p_ObjectFormatCode_ID IN RAW DEFAULT NULL,
p_PA_ID IN RAW DEFAULT NULL,
p_Name IN VARCHAR2 DEFAULT NULL,
p_FormatData IN BLOB DEFAULT NULL,
p_PF_ID IN OUT RAW )
RETURN INTEGER
AS
BEGIN
INSERT INTO PAGEFORMATS (PF_ID, ObjectFormatCode_ID, PA_ID, Name, FormatData) /* <---- this FormatData column is a BLOB column */
VALUES (p_PF_ID, p_ObjectFormatCode_ID, p_PA_ID, p_Name, p_FormatData)
END PAGEFORMATSINSERT;
<END ----------------------------------------->
The FormatData parameter has a data type of BLOB. In my Visual Basic, I have my ADODB.Command object. I am setting the CommandText of the Command object to "{? = call PageFormatsInsert(?, ?, ?, ?, ?)}". In order to set the parameter value for the BLOB data type, I am calling the AppendChunk function of the Command object - passing it a Byte array.
I am getting the folling error:
ERROR: -2147467259 [Oracle][ODBC][Ora]ORA-06550: line 1, column 13:
PLS-00306: wrong number or types of arguments in call to 'PAGEFORMATSINSERT'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
If I change the FormatData parameter to a LONG RAW parameter, I get the following error:
ERROR: -2147467259 [Oracle][ODBC][Ora]ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error
ORA-06512: at line 1
I am at a loss as to how to get binary data into by Oracle database. I need to do it using stored procedures. How can I set up my stored procedure or table to do what I want it to do? Should I change my table definition? Are there some settings in the ODBC connection I can tweak? How can I get the stored procedure to accept my call from VB ADO?
Any help would be appreciated.
wallyThanks for the idea, but I don't get how I am supposed to get my binary data to the stored procedure using the stream. I have a binary array that I want to pass to a stored procedure. I want to be able to use the same Visual Basic front end with out MSSQL database as with our Oracle database.
I am using the ADODB Connection and Command and RecordSet objects. Currenlty our front end calls the ADODB.Command(ParamNumber).AppendChunk function passing it the binary array. Somehow, the SQL Server driver does the magic in order for the MSSQL stored procedure to work correctly. I need to know how to do one of the following:
1. Get the Oracle driver to do the same magic.
2. Set up the Oracle stored procedure so I don't have to change the VB front end.
3. Change the VB front end so that it works with both MSSQL and Oracle.
wally -
Why the CLOB couldn't be inserted completely?
envirentment:
vc++ 6.0
database: oracle8i 8.1.7
ole provider: OraOLEDB.Oracle 8.1.7
I want to insert CLOB into oracle,but after inserted, dbms_lob.getlength(content) return the byte of the CLOB is less than original one,no error was reported in the process.for example,an article is 8k bytes long,but insert into oracle,it could be 7k or less.can anyone tell me why?help me!!!
the way i did:
connnect db...
connect string is: provider = OraOLEDB.Oracle ...
CString strCmd = "insert into t_article values (1,1,?)";
CommandPtr pCmd.CreateInstance(_uuidof(Command));
pCmd->ActiveConnection = m_pActiveConn;
ParameterPtr paraContentCont = m_pCommandCont->CreateParameter("Content",adLongVarChar,adParamInput,NEWSCONTENTLEN,_variant_t("null"));
TCHAR tcNewsContent[8k];//an article read from file
variantt vt_content = variantt(tcNewsContent);
vt_content.ChangeType(VT_BSTR);
pCmd->Parameters->GetItem("Content")->AppendChunk(vt_content);
pCmd->Execute(NULL,NULL,adCmdText|adExecuteNoRecords);
this operation was done successfully.but in sql*plus,select dbms_lob.getlength(content) from t_article where... the value is much less than the article file.
did i do anything wrong?I have a hard time reading C++ code. Any VB examples that demonstrate putting large Word .Doc's or Images into CLOB utilizing the AppendChunk method would be better for me.
I am developing using Visual Objects produced by Computer associates ( simuliar to VB ).
Here is some of my sample code:
oCmd := adoCommand{}
oCmd:ActiveConnection := oApp:Connection
oCmd:CommandText:= "INSERT INTO robtest (test,testattachment) values ('test',?)"
oCmd:CommandType:= adCmdText
aDir := Directory( 'C:\kids.zip' )
oPar := adoParameter{}
oPar:Name := 'testattachment'
oPar:Type := adLongVarChar
oPar:Size := LONGINT(aDir[1,F_SIZE])
oPar:Direction := adParamInput
ptrHandle := FOpen2( "C:\kids.zip", FO_READ )
dwBlock := 1024
// Position to the top of the file.
FSeek3(ptrHandle, 0 , FS_SET)
DO WHILE TRUE
sBuffer := Space(dwBlock)
dwReadText := FReadText(ptrHandle, @sBuffer, dwBlock )
IF Empty( dwReadText )
EXIT
ELSE
oPar:AppendChunk( sBuffer )
ENDIF
ENDDO
oCmd:Parameters_:Append( oPar )
oCmd:Execute( NIL, NIL, NIL )
*** By the way this code works perfectly when executing againg Microsoft SQL Server.
Cheers,
Rob Panosh -
I have been CLOBbered by Inserting CLOBS
I am using APS and trying to insert into a CLOB field.
I am using the ORACLE Provider to do it.
I am able to read just fine.
The problem comes when I insert (I have not even attempted Updating). I cannot push the 4000 character limit. I have been reading lots of forums and I am not able to get an answer that is not cryptic in nature. I have seen info about appendchunk but I am not getting it. You think it would be easier. I need to start from square 1.
Help me please!
VinceFezzzer wrote:
I have been informed by Orange (UK) that Apple have 'changed their rules' with regards to unlocking iPhones, and that it will take 6 months to process. Is this correct?
Complete rubbish
Apple do not lock iPhones
Carriers do because they have subsidised the purchase price
and therefore only the carrier can unlock an iPhone
Orange have decided to apply 6 months to protect their revenue
they never have been the fastest to unlock -
Oracle ODBC BLOB examples.
We are currently writing a VB application to harvest data from an Access 2000 database, which is to large to convert to 97 and use migration workbench, and stuff it into an Oracle 8 database, which already has the table structures from the Access dataabase created in it. We are running into a problem in transfering OLE objects in Access to BLOBs in Oracle. Can anyone give some insight / code examples?
Thanks,
Matt ShoultzWhen you get a chance, can you post the ADO version, or a link to it?
thanks.
Chris
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Justin Cave ([email protected]):
Unfortunately, I've never dealt with OLE objects in Access. I'm more than happy to help with BLOB's, though.
I'm posting a document below that covers reading & writing BLOB's with RDO under VB. Unfortunately, it's a little long, so I hope it doesn't get mangled too badly. If there's interest in an ADO version, let me know that as well and I'll post it on another thread.
If folks would like me to e-mail them a copy of this document, drop me a line. Expect it to take me at least a few days to reply to these requests, though.
PURPOSE
The code below should demonstrate how to read from and write to Oracle
8 BLOB datatypes.
SCOPE & APPLICATION
Experienced Visual Basic Developers.
RELATED DOCUMENTS
None.
The code below this demonstrates how to create a Visual Basic project
to read from and write to BLOB datatypes. It was written and tested using Visual
Basic 5 and RDO 2. The Oracle 8.0.5.2 ODBC driver was also used and an
Oracle 8.0.5 database.
Disclaimer:
This sample is provided for educational purposes only. It is NOT supported by
Oracle World Wide Technical Support. The sample has been tested and appears to
work as intended. However, you should always test in YOUR environment before
relying on it.
'Form Image Description
'~~~~~~~~~~~~~~~~~~~~~~
'The form needs 1 OLE control (OLE1) and 1 small text box (text 1) default value '1'
'it also needs 4 command buttons (AddNew,LoadFrom,LoadFromFile,SaveToDB)
'ODBC Datasource
'~~~~~~~~~~~~~~~
'Configure an 8.0.5.2 Oracle ODBC Driver Datasource named 'V805'
'Code required to generate database objects.
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'drop table tblTestBlob;
'CREATE TABLE tblTestBlob
' DATA_ID NUMBER(5,0),
' DATA_BlobData BLOB,
' DATA_MemoData CLOB
'INSERT INTO TBLTESTBLOB VALUES (1,EMPTY_BLOB(), EMPTY_CLOB());
Option Explicit
Dim en As rdoEnvironment
Dim Qd As rdoQuery
Dim Cn As rdoConnection
Dim Rs As rdoResultset
Dim SQL As String
Dim DataFile As Integer, Fl As Long, Chunks As Integer
Dim Fragment As Integer, Chunk() As Byte, I As Integer
Const ChunkSize As Integer = 16384
Dim fileName As String
Private Sub PipeToFile(sFileName)
Dim iFile As Integer
iFile = FreeFile
Open sFileName For Binary As iFile
Me.OLE1.SaveToFile iFile
DoEvents
Close iFile
End Sub
Private Sub AddNew_Click()
Dim sSQL As String
sSQL = "Select * from TBLTESTBLOB"
On Error GoTo errorhandler
Set Rs = Cn.OpenResultset(sSQL, rdOpenKeyset, rdConcurValues)
If Rs Is Nothing Or Rs.Updatable = False Then
MsgBox "Cant open or write to result set"
Exit Sub
End If
Rs.AddNew
Rs("DATA_ID") = Val(Me.Text1)
Rs("DATA_BLOBDATA").AppendChunk Null
Rs("DATA_MEMODATA").AppendChunk Null
Rs.Update
Rs.Close
Set Rs = Nothing
Exit Sub
errorhandler:
MsgBox "Add new click"
MsgBox Err.Number
MsgBox Err.Description
End Sub
Private Sub Form_Load()
On Error GoTo errorhandler
Set Cn = New rdoConnection
Cn.CursorDriver = rdUseOdbc
Cn.Connect = ";dsn=" & "V805" & ";uid=" & "scott" & ";pwd=" & "tiger"
Cn.EstablishConnection
Exit Sub
errorhandler:
MsgBox "Form Load"
MsgBox Err.Number
MsgBox Err.Description
End Sub
Private Function GetBLOBLength() As Long
Dim sSQL As String
Dim oResult As RDO.rdoResultset
On Error GoTo errorhandler
sSQL = "SELECT DBMS_LOB.GETLENGTH(DATA_BLOBDATA) FROM TBLTESTBLOB WHERE DATA_ID=" & Text1
Set oResult = Cn.OpenResultset(sSQL, rdOpenStatic)
GetBLOBLength = Val("" & oResult.rdoColumns(0).Value)
oResult.Close
Set oResult = Nothing
Exit Function
errorhandler:
MsgBox "Get BLOB Length"
MsgBox Err.Number
MsgBox Err.Description
End Function
Private Sub LoadFrom_Click()
Dim iNumBlocks As Integer
Dim lColSize As Long
Dim lBlockSize As Long
Dim byteData() As Byte
Dim lOffSet As Long
Dim iDestFileNum As Integer
Dim lLeftOver As Long
Dim iCount As Integer
Dim sSQL As String
On Error GoTo errorhandler
sSQL = "Select * from TBLTESTBLOB WHERE DATA_ID=" & Val(Text1)
Set Rs = Cn.OpenResultset(sSQL, rdOpenKeyset, rdConcurValues)
If Rs Is Nothing Or Rs.Updatable = False Then
MsgBox "Cant open or write to result set"
Exit Sub
End If
If Not Rs.EOF Then
lColSize = GetBLOBLength()
If lColSize <> 0 Then
iDestFileNum = FreeFile
Open "c:\TEST.DAT" For Binary As iDestFileNum
lBlockSize = 10000
iNumBlocks = lColSize \ lBlockSize
lLeftOver = lColSize Mod lBlockSize
For iCount = 1 To iNumBlocks
ReDim byteData(lBlockSize)
byteData() = Rs("DATA_BLOBDATA").GetChunk(lBlockSize) 'note offset not used by RDO (?)
Put iDestFileNum, , byteData()
lOffSet = lOffSet + lBlockSize 'note offset not used by RDO (?)
Next iCount
ReDim byteData(lLeftOver)
byteData() = Rs("DATA_BLOBDATA").GetChunk(lLeftOver) 'note offset not used by RDO (?)
Put iDestFileNum, , byteData()
Close iDestFileNum
iDestFileNum = FreeFile
Open "c:\TEST.DAT" For Binary As iDestFileNum
Me.OLE1.ReadFromFile iDestFileNum
Close iDestFileNum
End If
End If
Rs.Close
Set Rs = Nothing
Exit Sub
errorhandler:
MsgBox "Load From click"
MsgBox Err.Number
MsgBox Err.Description
End Sub
Private Sub LoadFromFile_Click()
' Locates a file and sets the Filename to this file.
On Error GoTo errorhandler
With CommonDialog1
.Filter = "*.*"
.ShowOpen
fileName = .fileName
End With
FileName_Change
Exit Sub
errorhandler:
MsgBox "Load from file"
MsgBox Err.Number
MsgBox Err.Description
End Sub
Private Sub SaveToDB_Click()
Dim sSQL As String
Dim sTempName As String
On Error GoTo errorhandler
sTempName = "c:\TEST.DAT"
Kill sTempName
PipeToFile sTempName
sSQL = "Select DATA_ID, DATA_BLOBDATA from TBLTESTBLOB WHERE DATA_ID=" & Val(Text1)
'sSQL = "Select DATA_Field1, DATA_IMAGE from TBLBIGDATA WHERE DATA_FIELD1=" & Val(Text1)
Set Rs = Cn.OpenResultset(sSQL, rdOpenKeyset, rdConcurValues)
If Rs Is Nothing Or Rs.Updatable = False Then
MsgBox "Cant open or write to result set"
Exit Sub
End If
If Not Rs.EOF Then
Rs.Edit
End If
DataFile = 1
Open sTempName For Binary Access Read As DataFile
Fl = LOF(DataFile) ' Length of data in file
If Fl = 0 Then
Close DataFile
Exit Sub
End If
Chunks = Fl \ ChunkSize
Fragment = Fl Mod ChunkSize
Rs("DATA_BLOBDATA").AppendChunk Null
ReDim Chunk(Fragment)
Get DataFile, , Chunk()
Rs("DATA_BLOBDATA").AppendChunk Chunk()
ReDim Chunk(ChunkSize)
For I = 1 To Chunks
Get DataFile, , Chunk()
Rs("DATA_BLOBDATA").AppendChunk Chunk()
Next I
Close DataFile
Rs.Update
Rs.Close
Set Rs = Nothing
MsgBox "Finish"
Exit Sub
errorhandler:
MsgBox "Save to DB"
MsgBox Err.Number
MsgBox Err.Description
End Sub
Private Sub FileName_Change()
On Error GoTo errorhandler
Me.OLE1.CreateEmbed fileName
Exit Sub
errorhandler:
MsgBox "File Name Change"
MsgBox Err.Number
MsgBox Err.Description
End Sub
Justin Cave
ODBC Development<HR></BLOCKQUOTE>
null
Maybe you are looking for
-
Hi, I need writing a help in a form and I have some informations to put in the help. I tried, this but I get an error at the end indicationg a @ is missing: $x = @" -Nom du produit tel que publié par le fabricant - Ne doit pas contenir d'espace -
-
Error in phase: DISASSEMBLE Reason for error: PATCH_FILE_READ_ERROR
Hello All I am applying support Package: SAPKB70009 on SAP ECC 6.0 for component SAP_BASIS with release 700. I am getting following error The import was stopped, since an error occurred during the phase DISASSEMBLE, which the Support Package Manager
-
How to Increase width of heading in search help list?
Hi..all.. I have created a search help exit with 7 fields in the output list. When I view the search help in the webdynpro screen, iam not able to view the result fully.,ie. the results are crumbled. the headings and data are not displayed fully. For
-
Ipod 5th gen Video, Windows XP, above system requirements. When I plug my Ipod into my compy (via usb) the computer recognizes it and iTunes as well. I can freely move music, video, podcasts into it. But if I set it to sync anything, it will display
-
there, Please Dear I have a problem in my laptop that really bothering me and I can't find a true solution, and also can't risk to try a friends suggestions, so may you please help me and here's problem