Thread:

From
"pakorn"
Date:
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
 
 
Attachment

Re:

From
"Dave Page"
Date:
 
-----Original Message-----
From: pakorn [mailto:pakorn_Nong@hotmail.com]
Sent: 18 May 2002 08:11
To: pgsql-odbc@postgresql.org
Subject: [ODBC]

Dear , Sir
    I use PostGreSQL on Redhat 7.1 and use VB6.0 connect by ODBC to PostGreSql
 
This sample code from VB
    ' Connect to the database using ODBC
    With cn
        .ConnectionString = "dsn=PostgreSQL;"
        .Open
        .CursorLocation = adUseClient
    End With

AND i cann't connect to Server have a message (in Attach file)
What i wrong please help me
 
Is your server running with tcp/ip connections enabled? Check $PGDATA/postgresql.conf, or make sure the postmaster is started with the -i option.
 
Regards, Dave.