X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id 9DE41CCD89 for ; Fri, 18 Jul 2003 17:45:50 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 09989-03 for ; Fri, 18 Jul 2003 17:46:21 +0000 (GMT) Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68]) by svr1.postgresql.org (Postfix) with ESMTP id 9D20ACCDB5 for ; Fri, 18 Jul 2003 14:45:47 -0300 (ADT) Received: from mascari.com (ferrari.mascari.com [192.168.2.1]) by corvette.mascari.com (8.11.6/8.11.6) with ESMTP id h6IHjq309712; Fri, 18 Jul 2003 13:45:52 -0400 Message-ID: <3F183250.5080703@mascari.com> Date: Fri, 18 Jul 2003 13:45:52 -0400 From: Mike Mascari User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Fred Parkinson Cc: "<" Subject: Re: Programmatic Access97 - > postgres login References: In-Reply-To: X-Enigmail-Version: 0.74.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/42 X-Sequence-Number: 3103 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