It WORKS! I am exultant. Hallelujah!

Поиск
Список
Период
Сортировка
От Typing80wpm@aol.com
Тема It WORKS! I am exultant. Hallelujah!
Дата
Msg-id 11.44647e1a.2fa526df@aol.com
обсуждение исходный текст
Список pgsql-odbc
 
Thanks for the link Jeff, that was exactly what I needed, plus a little brushing up in Visual Basic.
 
Here is the code which finally worked!
 
It DOES want the DSN to equal "PostgreSQL", rather than something else.
 
For some reason, certain commands DO NOT WORK, so I had to comment them out:
 
One of which is:
 
  'rs.Refresh
 
and, possibly, because rs.Refresh did not work, and got commented out, therefore, the recordcount commands worked, (compiled and ran with no error), but yielded an incorrect answer of - 1
 
  'Get the record count
  rs.MoveLast
  rs.MoveFirst
  MsgBox rs.RecordCount & " Records are in the recordset!"
 
 
===============================here is the code which works
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
 
  'Open the connection
  cn.Open "DSN=PostgreSQL;" & _
          "UID=neil;" & _
          "PWD=password;" & _
          "Database=bpsimple"
  '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 fname, lname FROM customer", 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!fname & ": " & rs!lname
    rs.MoveNext
  Wend
 
 
  'Insert a new record into the table
  cn.Execute "INSERT INTO customer (fname, lname, zipcode) VALUES ('hooray', 'Some random Data ', '123');"
 
  '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
====================end of code

В списке pgsql-odbc по дате отправления:

Предыдущее
От: Typing80wpm@aol.com
Дата:
Сообщение: VB questions re: Postgresql, Connect...etc
Следующее
От: "Raymond O'Donnell"
Дата:
Сообщение: Re: retrieving images stored by php / pgsql