From: Mike Mascari <mascarm@mascari.com>
To: Fred Parkinson <FredP@abag.ca.gov>
Cc: < <pgsql-odbc@postgresql.org>
Subject: Re: Programmatic Access97 - > postgres login
Date: Fri, 18 Jul 2003 13:45:52 -0400
Message-ID: <3F183250.5080703@mascari.com> (raw)
In-Reply-To: <sf17c1e9.032@groupwise.abag.ca.gov>
References: <sf17c1e9.032@groupwise.abag.ca.gov>
Fred Parkinson wrote:
> Can anybody point me to how to programatically log in to our Postgres
> database? Using Access'97 built-in capabilities I have successfully
> linked to and used the Postgres tables for a while now. Naturally I am
> asked for the username and password when the app starts up, and this has
> never been a problem. Now I want to run an automatic process each night
> and want to do so without a person present to type in the username and
> password.
You should:
1) Turn ODBC tracing on
2) Examine the log for the connection string
3) Execute the connection-string-adjusted version of the following VBA
as appropriate. This function takes a userid, password, and database
name from a Login dialog (form) and constructs the Connect string from
that. If you want to embed the userid/password then you would just use
a constant connection string, but you get the idea:
----
Sub PreConnect(strUserName As String, strPassword As String,
strDatabase As String)
Dim wrkRemote As Workspace, dbsRemote As Database
Dim strConnect As String
strConnect = "ODBC;DSN=PostgreSQL;DATABASE=" + strDatabase +
";SERVER=pgserver;PORT=5432;UID=" + strUserName + ";PWD=" +
strPassword +
";READONLY=0;PROTOCOL=6.4;FAKEOIDINDEX=0;SHOWOIDCOLUMN=0;ROWVERSIONING=0;SHOWSYSTEMTABLES=1;CONNSETTINGS="
Set wrkRemote = DBEngine.Workspaces(0)
Set dbsRemote = wrkRemote.OpenDatabase("", False, False, strConnect)
dbsRemote.Close ' Close database but keep connection.
End Sub
----
Note: This is from an older interface whose ODBC parameters might have
changed with newer ODBC versions, so just yank the connection string
from the ODBC trace.
Hope that helps,
Mike Mascari
mascarm@mascari.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: mascarm@mascari.com, FredP@abag.ca.gov
Subject: Re: Programmatic Access97 - > postgres login
In-Reply-To: <3F183250.5080703@mascari.com>
References: <sf17c1e9.032@groupwise.abag.ca.gov> <3F183250.5080703@mascari.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox