RE: [INTERFACES] VB and ODBC - Mailing list pgsql-odbc

From Dave Page
Subject RE: [INTERFACES] VB and ODBC
Date
Msg-id 8568FC767B4AD311AC33006097BCD3D61A2AFB@woody.vale-housing.co.uk
Whole thread Raw
Responses RE: [INTERFACES] VB and ODBC  ("Graham Vickrage" <graham@digitalplanit.com>)
List pgsql-odbc
[CC'd to the ODBC List]
 
Graham,
 
I wouldn't have thought that you would need any extra libraries (all you should need come with MDAC) - though you may need to reference them from within your project. In VB you do this in the Project -> References  menu option. I use ADO technology for which you need the 'Microsoft ActiveX Data Objects 2.6 Library'. There are also earlier versions you could use (2.5, 2.1 or 2.0).
 
Basic code to open a connection, run a query and iterate though the results would look like:
 
Sub Main()
Dim cn as New ADODB.Connection
Dim rs as New ADODB.Recordset
 
  'Open the connection
  cn.Open "DSN=PostgreSQL;UID=dave;PWD=password;"
 
  'Open the recordset
  rs.Open "SELECT relname FROM pg_class", cn
 
  'Loop though the recordset print the results
  While Not rs.EOF
    Debug.Print rs!relname
    rs.MoveNext
  Wend
 
  'Cleanup
  If rs.State <> adStateClosed Then rs.Close
  Set rs = Nothing
  If cn.State <> adStateClosed Then cn.Close
  Set cn = Nothing
End Sub
 
HTH, Regards,
 
Dave.
-----Original Message-----
From: Graham Vickrage [mailto:graham@digitalplanit.com]
Sent: 28 April 2001 14:35
To: Dave Page
Subject: RE: [INTERFACES] VB and ODBC

Dave,
 
I am using VBA, is it a case that the solution you have needs libraries that only Studio has? If this is the case then could I not import these libraries? Maybe the code would be useful even so, if you don't mind sending it me it would be a great help.
 
Cheers
 
Graham
-----Original Message-----
From: Dave Page [mailto:dpage@vale-housing.co.uk]
Sent: 27 April 2001 21:03
To: 'Graham Vickrage'; Michael Ansley (UK); pgsql-interfaces@postgresql.org
Subject: RE: [INTERFACES] VB and ODBC

 
-----Original Message-----
From: Graham Vickrage [mailto:graham@digitalplanit.com]
Sent: 27 April 2001 18:03
To: Michael Ansley (UK); pgsql-interfaces@postgresql.org
Subject: RE: [INTERFACES] VB and ODBC

Thanks for the advice, but I seem to still be having probs.
 
I can't leave out the name param as its required so the only option is to leave it blank. If I put anything else in its place then it comes back with an error that the files does not exist.
 
When I give an empty string as the name there are no errors, so assuming this is working how do I then extract the data from the dataconnectioin and print it in the doc?
 
With perl DBI it might be something like
$query = DBI->connect(etc...) ;
$query->fetchrow();
 
What it the equivelant for VB? 
 
From your earlier post aren't you actually using VBA (Visual Basic for Applications)? i.e. in Word - if not let me know and I'll post some sample VB (as in the part of Visual Studio) code for you.
 
As for the ODBC driver, the office PostgreSQL driver is available at ftp://ftp.postgresql.org/pub/odbc. There are .dlls in the Versions directory, and in the test directory is a full installation which seems to work well.
 
hth, regards Dave.

pgsql-odbc by date:

Previous
From: "Jean-Sébastien ANDUJAR"
Date:
Subject: Drivers ODBC
Next
From: Hiroshi Inoue
Date:
Subject: Re: [HACKERS] Bug in ODBC driver