How I connected to pgsql using M$ visual basic - Mailing list pgsql-novice

From marco cassisa
Subject How I connected to pgsql using M$ visual basic
Date
Msg-id 000501bfc11f$067a79a0$36e5b6c3@k6e2g8
Whole thread Raw
List pgsql-novice
hi,
i searched the information i posting, but can't find it, even in this ml.
now that i know how to connect to my postgresql server using visualbasic, i
post this little sub
using access, it should be easier, because access has the object docmd which
has the method transferdatabase

i commented out the code which should delete the table (if exist). if it
does not exist, an error (err 3146) is raised: but it is too generic!
any suggestion?
bye

----------------------------------------
Private Sub cmdConnect_click()
On Error goto Vammona
Dim cnnLinox As Connection
Dim wrkODBC As Workspace
Dim rst As Recordset, tbl As TableDef
Dim fld1 As String
Dim qdf As QueryDef

Dim strConn As String
    Set wrkODBC = CreateWorkspace("NewODBCWorkspace", "admin", "",
dbUseODBC)
    Set dbs = OpenDatabase("video.mdb")
    strConn = "ODBC;Driver={PostgreSQL};DSN='C:\Programmi\File
comuni\ODBC\Data
Sources\test.dsn';server='http://linox.tecnoprogress.it';port='5432';dbase='
test';USER='marco';passwd='xxx;onlyread='1';protocol='6.4';showoid='0';fakeo
idindex='0',showsystable='0'"
    strConn =
"ODBC;DRIVER={PostgreSQL};DATABASE=test;SERVER=linox.tecnoprogress.it;PORT=5
432;UID=marco;PWD=xxx;READONLY=0;PROTOCOL=6.4;FAKEOIDINDEX=0;SHOWOIDCOLUMN=0
;ROWVERSIONING=0;SHOWSYSTEMTABLES=0;CONNSETTINGS='"
    Set cnnLinox = wrkODBC.OpenConnection("", dbDriverNoPrompt, , strConn)

    'Set qdf = cnnLinox.CreateQueryDef("", "DROP TABLE videolino;")
    'wrkODBC.BeginTrans
    'qdf.Execute
    'wrkODBC.CommitTrans

    Set qdf = cnnLinox.CreateQueryDef("", "CREATE TABLE videolino (titolo
varchar(30);")
    qdf.Execute

    'popola la tabella remota!
    Set rst = dbs.OpenRecordset("tTempInternet")
    rst.MoveFirst
    wrkODBC.BeginTrans
    Do While Not rst.EOF
            If IsNull(rst!field1) Then
                tit = "NULL"
            Else
                tit = "'" & rst!field1 & "'"
            End If
            strConn = "INSERT INTO videolino VALUES (" & tit & "");"
           Set qdf = cnnLinox.CreateQueryDef("", strConn)
           qdf.Execute
           rst.MoveNext
           DoEvents
    Loop
    wrkODBC.CommitTrans

    cnnLinox.Close
    wrkODBC.Close

Exit Sub
if Err.Number=3146 Then
    cnnLino.Rollback
    MsgBox("Something is wrong!")
    Exit Sub
Else
    MsgBox Err.Number
    Exit Sub
End If
End Sub
------------------------------------------------------------------

bye
marco cassisa
cassisa@unive.it
marco@linox.tecnoprogress.it


pgsql-novice by date:

Previous
From: gomathi raju
Date:
Subject: Problem -- pgc
Next
From: Michael Knigge
Date:
Subject: Lowercase