-----Original Message----- From: Darrik Mazey [mailto:[EMAIL PROTECTED] Sent: Friday, May 02, 2003 6:09 PM To: Eric Hansen Subject: RE: [perl-win32-gui-users] Microsoft Access database connection string
this is a snippet from code that i wrote recently using DBI and DBD::ODBC and microsoft access 2000 on win2000 advanced server. hope it helps. my $dsn="driver=Microsoft Access Driver (*.mdb);dbq=c:\\path\\to\\database.mdb;"; my $connstr="DBI:ODBC:$dsn"; my $dbh=DBI->connect($connstr) or die("could not connect to database [$connstr]"); it works for me. darrik -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Eric Hansen Sent: Friday, May 02, 2003 11:03 AM To: perl-win32-gui-users@lists.sourceforge.net Subject: Re: [perl-win32-gui-users] Microsoft Access database connection string You can create a text file with the following information on the fly and output it to a filename and directory of your choice. I give mine a *.dsn extension. Notice DefaultDir= and DBQ= should point to the directory and filename you output the DSN info to. [ODBC] DRIVER=Microsoft Access Driver (*.mdb) UID=admin UserCommitSync=Yes Threads=3 SafeTransactions=0 PageTimeout=5 MaxScanRows=8 MaxBufferSize=512 FIL=MS Access DriverId=281 DefaultDir='\\server\directorypath' DBQ='\\server\directorypath\databasename.mdb' Then in your program include this use clause at the top: use Win32::ODBC; Then later in your program add a couple subroutines that You can call to open and close the database. sub Open_Database() { my $FILEDSN="FILEDSN=\\\\server\\directorypath\\databasename.dsn"; $db = new Win32::ODBC($FILEDSN); if (! $db) { my $error=Win32::ODBC::Error(); Win32::GUI::MessageBox($WindowName, "Can't Establish Database Connection using:\n$FILEDSN\n$error", "Application Name - Error",16,); return 1; } return 0; } sub Close_Database() { $db->Close(); # close the database connection undef $db; }