VBA 6 crashes with WIN2K, Postgres 8.1, why ? which dll ??

From: linuxgps <linuxgps(at)invitel(dot)hu>
To: pgsql-odbc(at)postgresql(dot)org
Subject: VBA 6 crashes with WIN2K, Postgres 8.1, why ? which dll ??
Date: 2006-01-06 04:12:26
Message-ID: 43BDEE2A.1060809@invitel.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Hi all,

I'm a beginner to MS Windows.
I began to to test VBA 6.0(SP6) with Postgresql 8.1 -with odbc- on
WIN2K(SP4).
For the test (accessing postgres db thru visual basic) I use the code,
given by the distro (psqlODBC HOWTO- Visual Basic).
The first problem I've encounted that the code in the given test snippet
is not full functioning:
"rs.Refresh" doesn't implemented ?
I use in the "Project Preferences" "Microsoft ActiveXData Objects 2.1
library (msado21.tlb)

I've installed some other MS stuff on the machine, and now the Postgres
database call makes a memory exception and crashes.

Q 1.: Is this general, or some libraries are wrong on my system ?
Q 2.: Which MS tools are to control/update the msado-libraries
Q.3.: Which msado or similars are necessary to connect with visual basic
to postgres ?

thank you in advance
testuser vba

-----------------

Sub Main()
Dim cn as New ADODB.Connection
Dim rs as New ADODB.Recordset

'Open the connection
cn.Open "DSN=<MyDataSourceName>;" & _
"UID=<MyUsername>;" & _
"PWD=<MyPassword>;" & _
"Database=<MyDatabaseName>"

'For updateable recordsets we would typically open a Dynamic recordset.
'Forward Only recordsets are much faster but can only scroll forward and
'are read only. Snapshot recordsets are read only, but scroll in both
'directions.
rs.Open "SELECT id, data FROM vbtest", cn, adOpenDynamic

'Loop though the recordset and print the results
'We will also update the accessed column, but this time access it through
'the Fields collection. ISO-8601 formatted dates/times are the safest IMHO.
While Not rs.EOF
Debug.Print rs!id & ": " & rs!data
rs.Fields("accessed") = Format(Now, "yyyy-MM-dd hh:mm:ss")
rs.Update
rs.MoveNext
Wend

'Add a new record to the recordset
rs.AddNew
rs!id = 76
rs!data = 'More random data'
rs!accessed = Format(Now, "yyyy-MM-dd hh:mm:ss")
rs.Update

'Insert a new record into the table
cn.Execute "INSERT INTO vbtest (id, data) VALUES (23, 'Some random data');"

'Refresh the recordset to get that last record...
rs.Refresh

'Get the record count
rs.MoveLast
rs.MoveFirst
MsgBox rs.RecordCount & " Records are in the recordset!"

'Cleanup
If rs.State <> adStateClosed Then rs.Close
Set rs = Nothing
If cn.State <> adStateClosed Then cn.Close
Set cn = Nothing
End Sub

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message linuxgps 2006-01-06 05:22:01 VBA 6 crashes with WIN2K, Postgres 8.1, why ? which dll ??-> exception error
Previous Message noreply 2006-01-05 19:41:37 [ psqlodbc-Bugs-1000519 ] Does not pick up default username