From: pakorn <pakorn_Nong@hotmail.com>
To: pgsql-odbc@postgresql.org
Date: Sat, 18 May 2002 14:10:44 +0700
Message-ID: <LAW2-OE67NYkIhsZSls0000794a@hotmail.com> (raw)
Dear , Sir
I use PostGreSQL on Redhat 7.1 and use VB6.0 connect by ODBC to PostGreSql
This sample code from VB
Private Sub ADO_Store()
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 main As ADODB.Parameter
Dim object As ADODB.Parameter
' Connect to the database using ODBC
With cn
.ConnectionString = "dsn=PostgreSQL;"
.Open
.CursorLocation = adUseClient
End With
' Here is an example if you want to issue a direct command to the database
'
'Set cmd = New ADODB.Command
'With cmd
' .CommandText = "delete from MYTABLE"
' .ActiveConnection = cn
' .Execute
'End With
'Set cmd = Nothing
'
' Here is an example of how insert directly into the database without using
' a recordset and the AddNew method
'
Set cmd = New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandText = "insert into MYTABLE(main,object) values(?,?)"
cmd.CommandType = adCmdText
' The main parameter
Set main = cmd.CreateParameter("main", adInteger, adParamInput)
main.Value = 100 '' a random integer value ''
cmd.Parameters.Append main
' Open the file for reading
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
' The object parameter
'
' The fourth parameter indicates the memory to allocate to store the object
Set object = cmd.CreateParameter("object", _
adLongVarBinary, _
adParamInput, _
flen + 100)
ReDim chunk(1 To flen)
Get fd, , chunk()
' Insert the object into the parameter object
object.AppendChunk chunk()
cmd.Parameters.Append object
' Now execute the command
Set rs = cmd.Execute
' ... and close all
cn.Close
Close
End Sub
Private Sub Command1_Click()
Call ADO_Store
End Sub
AND i cann't connect to Server have a message (in Attach file)
What i wrong please help me
Thank you
Me.Pakorn Uawacharo
Thailand
Attachments:postgre.jpg (image/jpeg, 21.9K) downloadview imageErrPost.jpg (image/jpeg, 15.0K) downloadview image
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: pakorn_Nong@hotmail.com
Subject: Re:
In-Reply-To: <LAW2-OE67NYkIhsZSls0000794a@hotmail.com>
References: <LAW2-OE67NYkIhsZSls0000794a@hotmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox