pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
(no subject)
1+ messages / 1 participants
[nested] [flat]

* (no subject)
@ 2002-05-18 07:10  pakorn <pakorn_Nong@hotmail.com>
  0 siblings, 0 replies; 1+ messages in thread

From: pakorn @ 2002-05-18 07:10 UTC (permalink / raw)
  To: pgsql-odbc

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) download view image
ErrPost.jpg (image/jpeg, 15.0K) download view image
^ permalink raw reply [nested|flat] 1+ messages in thread


only message in thread

Thread overview: 1+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-05-18 07:10  pakorn <pakorn_Nong@hotmail.com>

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