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

From: Hiroshi Inoue <Inoue(at)tpf(dot)co(dot)jp>
To: Denis Gasparin <denis(at)edinet(dot)it>
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 06:05:54
Message-ID: 3BD65A42.FB57EB12@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-odbc

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
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Colin 't Hart 2001-10-24 07:08:47 Re: Evaluating PostgreSQL
Previous Message Hiroshi Inoue 2001-10-24 05:58:42 Re: [GENERAL] Using an SMP machine to make multiple indices on the same

Browse pgsql-odbc by date

  From Date Subject
Next Message Denis Gasparin 2001-10-24 09:54:45 Re: [ODBC] Writing BLOBS to pgsql via ODBC using VB
Previous Message Denis Gasparin 2001-10-23 13:52:56 Re: [ODBC] Writing BLOBS to pgsql via ODBC using VB