Skip site navigation (1) Skip section navigation (2)

Re: [ODBC] Writing BLOBS to pgsql via ODBC using VB

From: Denis Gasparin <denis(at)edinet(dot)it>
To: Hiroshi Inoue <Inoue(at)tpf(dot)co(dot)jp>
Cc: pgsql-odbc(at)postgresql(dot)org, Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: [ODBC] Writing BLOBS to pgsql via ODBC using VB
Date: 2001-10-24 09:54:45
Message-ID: 5.1.0.14.0.20011024114055.00a8ccb0@10.1.1.2 (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-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


In response to

Responses

pgsql-odbc by date

Next:From: Hiroshi InoueDate: 2001-10-24 15:23:16
Subject: Re: Writing BLOBS to pgsql via ODBC using VB
Previous:From: Hiroshi InoueDate: 2001-10-24 06:05:54
Subject: Re: [ODBC] Writing BLOBS to pgsql via ODBC using VB

pgsql-general by date

Next:From: Martijn van OosterhoutDate: 2001-10-24 10:13:15
Subject: Re: Disable Transaction - plans ?
Previous:From: Ben-Nes MichaelDate: 2001-10-24 09:23:49
Subject: Disable Transaction - plans ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group