Skip site navigation (1) Skip section navigation (2)

RE: [INTERFACES] VB and ODBC

From: Dave Page <dpage(at)vale-housing(dot)co(dot)uk>
To: "'Graham Vickrage'" <graham(at)digitalplanit(dot)com>, "'pgsql-odbc(at)postgreSQL(dot)org'" <pgsql-odbc(at)postgreSQL(dot)org>
Subject: RE: [INTERFACES] VB and ODBC
Date: 2001-04-30 07:25:09
Message-ID: 8568FC767B4AD311AC33006097BCD3D61A2AFB@woody.vale-housing.co.uk (view raw or flat)
Thread:
Lists: 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(at)digitalplanit(dot)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(at)vale-housing(dot)co(dot)uk]
Sent: 27 April 2001 21:03
To: 'Graham Vickrage'; Michael Ansley (UK); pgsql-interfaces(at)postgresql(dot)org
Subject: RE: [INTERFACES] VB and ODBC


 

-----Original Message-----
From: Graham Vickrage [mailto:graham(at)digitalplanit(dot)com]
Sent: 27 April 2001 18:03
To: Michael Ansley (UK); pgsql-interfaces(at)postgresql(dot)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 <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.

Responses

pgsql-odbc by date

Next:From: Jan WieckDate: 2001-04-30 13:05:36
Subject: Bug in ODBC driver
Previous:From: Jean-S├ębastien ANDUJARDate: 2001-04-27 11:57:24
Subject: Drivers ODBC

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group