Writing BLOBS to pgsql via ODBC using VB - Mailing list pgsql-odbc

From Denis Gasparin
Subject Writing BLOBS to pgsql via ODBC using VB
Date
Msg-id 5.1.0.14.0.20011019180458.00a68b90@10.1.1.2
Whole thread Raw
List pgsql-odbc
I am having problems while trying to insert a BLOB into a pgsql table using VB.
The error i get is:
         S1090: [Microsoft][ODBC Driver Manager] Invalid String or buffer
length

I am using postgresql 7.1.3, Postgresql ODBC driver 7.01.00.07 and RDO 2.0

Have you any idea why i get this error?


Additional infos:

Here is the table definition:
CREATE TABLE MYTABLE (
         MAIN INTEGER NOT NULL PRIMARY KEY,
         OBJECT LO
);

Here is the code:

Private Sub Command1_Click()

Dim rdoConn As New rdoConnection, rdoRS As rdoResultset, SQL As String
Dim numfile As Integer
Dim filesize As Long
Dim query As rdoQuery
Dim chunk() As Byte

' DB Connection
With rdoConn
         .Connect = "uid=myuser;pwd=mypwd;DSN=BLOB_TEST;"
         .CursorDriver = rdUseOdbc
         .LoginTimeout = 3
         .EstablishConnection rdDriverNoPrompt
End With
Set query = rdoConn.CreateQuery("MyQuery", "select * from mytable")
Set rdoRS = query.OpenResultset(rdOpenKeyset, rdConcurRowVer)
If rdoRS Is Nothing Or rdoRS.Updatable = False Then
         MsgBox "Cannot create rdoResultSet"
         End
End If

' Now insert the record in the table
If rdoRS.EOF Then
         ' Insert a new record
         rdoRS.AddNew

         ' The MAIN field
         rdoRS!MAIN = 2678

         ' Get a file number
         numfile = FreeFile

         ' Open the file i've to insert in the table
         Open "c:\myfile.doc" For Binary Access Read As #numfile
         filesize = LOF(numfile)
         If filesize = 0 Then
                 MsgBox "Unable to open the file"
                 Close
                 End
         End If

         ReDim chunk(filesize)

         ' Read the file into the array
         Get #numfile, , chunk()

         ' Try to insert
         rdoRS!OBJECT.AppendChunk chunk()

         ' In the update statement i get the error
         rdoRS.Update
         Close #numfile
         End If
End Sub


Regards,


Doct. Eng. Denis
Gasparin                                             denis@edistar.com
---------------------------------------------------------------------------------------
Programmer & System
Administrator                                http://www.edistar.com
---------------------------------------------------------------------------------------
                              Well alas we've seen it all before
                               Knights in armour, days of yore
                          The same old fears and the same old crimes
                            We haven't changed since ancient times

                               -- Iron Hand -- Dire Straits --
---------------------------------------------------------------------------------------


pgsql-odbc by date:

Previous
From: "Eiji Tokuya"
Date:
Subject: Re: Support for Special Big5 double-byte characters
Next
From: "Ryan C. Bonham"
Date:
Subject: -2147217842 Operation was canceled