pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feedVB functions for postgres
2+ messages / 2 participants
[nested] [flat]
* VB functions for postgres
@ 2003-02-19 09:29 raymond.chuasing@kasal.com
0 siblings, 1 reply; 2+ messages in thread
From: raymond.chuasing@kasal.com @ 2003-02-19 09:29 UTC (permalink / raw)
To: pgsql-odbc
I succeeded in connecting my vb application to a postgres db , I used this
code to connect
Dim MyConn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim MySQL As String
Dim rec_count As Long
MyConn.Open "DSN=PostgreSQL", "Mondi", "1234"
Set rs = New ADODB.Recordset
rs.Open "select * from userinfo;", Myconn, adOpenDynamic
then I use the Myconn.execute to execute some sql querries
Heres the prob:
- I don't know how to navigate thru the recordset
- rs.recordcount does not work
- only rs.movenext work
- when the table is empty or when you use movenext and there are no more
entries it creates an error msg : " runtime error 3021 either bof or eof
is true or the current record is deleted requested operation requires a
current record"
* I have read the tutorial on connecting visual basic to psqlODBC but the
codes there don't work.... :(
can anyone help me .... thx
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: VB functions for postgres
@ 2003-02-19 09:57 Mike Miller <mike@psy.otago.ac.nz>
parent: raymond.chuasing@kasal.com
0 siblings, 0 replies; 2+ messages in thread
From: Mike Miller @ 2003-02-19 09:57 UTC (permalink / raw)
To: raymond.chuasing@kasal.com; pgsql-odbc
-----Original Message-----
<SNIP>
> MyConn.Open "DSN=PostgreSQL", "Mondi", "1234"
> Set rs = New ADODB.Recordset
> rs.Open "select * from userinfo;", Myconn, adOpenDynamic
> then I use the Myconn.execute to execute some sql querries
>
> Heres the prob:
> - I don't know how to navigate thru the recordset
Try something like this. It will get you started ;)
Write back if you have trouble.
Set rsInfo = New ADODB.Recordset
With rsInfo
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.ActiveConnection = adoConnection
.Open "select Name, Description from userinfo"
' Make sure there are records
If Not .BOF And Not .EOF Then
' Move to the first record
.MoveFirst
' While not at the end (there are more records)
While Not .EOF
' Do stuff with row
Debug.Print .Fields("Name").Value
Debug.Print .Fields("Description").Value
' DoEvents so that app doesn't hang and move to
the next record
DoEvents
.MoveNext
Wend
End If
' Close the recordset
.Close
End With
--
Mike Miller,
Computer Programmer,
Department of Pyschology,
University Of Otago
mike@psy.otago.ac.nz
+64 3 479 5402
...when you lay awake at night hoping that those elves from "The Elves
and the Shoemaker" know where you work and can program in C++ as well as
they can sew together sandles...
-- stolen from (http://www.gameai.com/youknow.html)
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-02-19 09:57 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-02-19 09:29 VB functions for postgres raymond.chuasing@kasal.com
2003-02-19 09:57 ` Mike Miller <mike@psy.otago.ac.nz>
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