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

From Denis Gasparin
Subject Re: Writing BLOBS to pgsql via ODBC using VB
Date
Msg-id 5.1.0.14.0.20011024114055.00a8ccb0@10.1.1.2
Whole thread Raw
In response to Re: Writing BLOBS to pgsql via ODBC using VB  (Hiroshi Inoue <Inoue@tpf.co.jp>)
Responses Re: Writing BLOBS to pgsql via ODBC using VB  ("Hiroshi Inoue" <Inoue@tpf.co.jp>)
List pgsql-odbc
Ok, it worked again...
Thank you very much for your help.

If i write a little document about visual basic, ADO and LO object can I
post to you or to the mailing list? I think this will help all those
persons (like me) that are forced to use M$ products or windows based
software...

Denis



At 24/10/01 08.05, Hiroshi Inoue wrote:
>How about the following ?
>
>Denis Gasparin wrote:
> >
> >  > Are you setting the CursorLocation memeber as adUseClient ?
> >  >
> >  >regards,
> >  >Hiroshi Inoue
> >
> > Ok, it worked. I think that it would be great to insert that tip in the faq
> > at the odbc.postgresql.org.
> >
> > Now another question:
> > is there possible to use lo with parameterized queries (ADO command
> object)?
> > I have tried but i receive a query error. It seems like the odbc driver
> > doesn't use the lo interface but tryies to insert the record into the db as
> > if the field was of bytea type (Sorry for the poor English...I hope it is
> > clear what i'm saying...)
> >
> > At the end of the mail there is the code and the log of the odbc pgsql
> driver.
> > The table is the same of the other mail: two fields, main (of type integer)
> > and object (of type lo)
> >
> > Thank for your help,
> >
> > Denis
> >
> > --- DEBUG INFORMATIONS ---
> > At the end of the mail there is the pgsql odbc driver log. Here instead
> > there is the code:
> >
> > Dim cn As New ADODB.Connection
> > Dim rs As ADODB.Recordset
> > Dim cmd As ADODB.Command
> > Dim chunk() As Byte
> > Dim fd As Integer
> > Dim flen As Long
> > Dim chunks As Integer
> > Dim fragment As Integer
> > Dim main As ADODB.Parameter
> > Dim object As ADODB.Parameter
> > Dim i As Long
> >
> > With cn
> >      .ConnectionString = "dsn=pgsql_test_blob;"
> >      .Open
> >      .CursorLocation = adUseClient
> > End With
> >
> > Set cmd = New ADODB.Command
> > With cmd
> >      .CommandText = "delete from myt1"
> >      .ActiveConnection = cn
> >      .Execute
> > End With
> >
> > Set cmd = Nothing
> >
> > Set cmd = New ADODB.Command
> > cmd.ActiveConnection = cn
> > cmd.CommandText = "insert into myt1(main,object) values(?,?)"
> > cmd.CommandType = adCmdText
> >
> > ' Set the main parameter
> > Set main = cmd.CreateParameter("main", adInteger, adParamInput)
> > main.Value = 1234
>' add the following
>   cmd.Parameters.Append main
>
> >
> > Set object = cmd.CreateParameter("object", adLongVarBinary,
>adParamInput)
>
>' change as follows(100000 should be large enough)
>Set object = cmd.CreateParameter("object", adLongVarBinary,
>adParamInput, 100000)
>' add the following
>cmd.Parameters.Append object
>
> > fd = FreeFile
> > Open "mydocument" For Binary Access Read As fd
> > flen = LOF(fd)
> > If flen = 0 Then
> >      Close
> >      MsgBox "Error while opening the file"
> >      End
> > End If
> > ReDim chunk(flen)
> > Get fd, , chunk()
> > ' Now insert into the parameter
> > object.AppendChunk chunk()
> >
> > ' Execute the insert command
> > Set rs = cmd.Execute(, Array(main, object))
>
>' Change as follows
>Set rs = cmd.Execute
>
> > cn.Close
> > Close
> >
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster


pgsql-odbc by date:

Previous
From: Hiroshi Inoue
Date:
Subject: Re: Writing BLOBS to pgsql via ODBC using VB
Next
From: "Hiroshi Inoue"
Date:
Subject: Re: Writing BLOBS to pgsql via ODBC using VB