RE: VB and ODBC

From: "Michael Ansley (UK)" <Michael(dot)Ansley(at)intec-telecom-systems(dot)com>
To: "'Graham Vickrage'" <graham(at)digitalplanit(dot)com>, pgsql-interfaces(at)postgresql(dot)org
Subject: RE: VB and ODBC
Date: 2001-04-27 15:05:19
Message-ID: 7F124BC48D56D411812500D0B747251480F56C@fileserver002.intecsystems.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

When using Access, because it is essentially a file-based db, rather
than server-based, you give the filename. With Postgres, you will
probably not have to give the data source a name, but you will have
to change the parameters in the connection string. I think that the
Name parameter is used to give the connection a name internal to the
script that you're running. It's only a temporary thing. The
connection string should probably be something like:

constr = "ODBC;DSN=Your_DSN;UID=user;PWD=password"

Your_DSN needs to be a DSN that you have already defined in the
control panel, user needs to be the database user, and password for
the password, if it's required. You may also get away with this:

constr =
"ODBC;Driver={PostgreSQL};SERVER=Your_Server;DATABASE=Your_Database;UI
D=user;PWD=password"

which means that you don't have to create the DSN beforehand. The
DATABASE keyword may not be right, but I can't remember what it is
offhand for Postgres. Each vendor has it's own set of keywords,
although UID and PWD seem to be pretty universal, and the ODBC prefix
is always required for ODBC connections (remember, DAO doesn't assume
that you want to use ODBC, you have to tell it). If you feel like
tracing the connection (using the first method), then you can find
out what the keywords are ;-) and use the second.

Cheers...

MikeA

>> -----Original Message-----
>> From: Graham Vickrage [mailto:graham(at)digitalplanit(dot)com]
>> Sent: 27 April 2001 12:18
>> To: pgsql-interfaces(at)postgresql(dot)org
>> Subject: [INTERFACES] VB and ODBC
>>
>>
>> I am a new to ODBC and relatively new to VB. I am trying to make a
>> connection to a postgres 7.0 DB from word via a VB macro. I
>> think I have
>> installed the ODBC driver correctly (win98) and am trying to make
>> a connection via the VB module using the following.
>>
>> Sub ClientOrder()
>> With ActiveDocument.MailMerge
>> .MainDocumentType = wdFormLetters
>> constr = "DSN=PostgreSQL;" _
>> & "FIL=RedISAM;"
>> .OpenDataSource Name:="dbname", _
>> Connection:=constr, SQLStatement:="SELECT Client_order_id
>> FROM client_order"
>> End With
>> End Sub
>>
>> This does not work I think because of the .OpenDataSource
>> Name:="dbname". In
>> other examples (ie access) it points directly the the DB File ie
>> 'c:/somefile.mdb'. How would this work for postgres, is
>> there an equivilant
>> on the linux box (I think not). Or could someone point me to
>> some examples
>> of this.
>>
>> Thanks in advance
>>
>> Graham
>>
>>
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 3: if posting/reading through Usenet, please send an
>> appropriate subscribe-nomail command to majordomo(at)postgresql(dot)org
>> so that your message can get through to the mailing list cleanly
>>

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBOumJhXympNV/C086EQL99QCg2AAXwiurv69MuAp5Mjqd8xdYGo8AoNx1
cQbDKazTLrPd9hGleKk9b5tV
=hU5o
-----END PGP SIGNATURE-----

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message J. T. Vermeulen 2001-04-27 16:47:55 Re: persistent connection with c++
Previous Message Alexey Nalbat 2001-04-27 12:50:21 Re: can external C-function get multiple rows?