> From: Kevin Carothers <[EMAIL PROTECTED]> > Date: 2005/03/30 Wed PM 06:44:48 CST
> 1. Create an ODBC connection via %SystemRoot%\system32\odbcad32.exe > Call the database connect name "ODBCName" > > 2. In your Perl code add: > [---] > use DBI; > [---] > $dbh = DBI->connect("dbi:ODBC:ODBCName",'',''); > [---] Just my opinion, but I don't think this is good advice. For one, it creates extra administration on the system, by forcing the user/programmer /sysadmin/webadmin to create an ODBC DSN setting for every new setup. For two, DBI and ODBC both support dynamic DSNs, so why not use them? Here is a connect string that works for Access databases: my $dbh = DBI->connect( "dbi:ADO::Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=$path_to_mdb_file" ,'admin', {RaiseError => 1, AutoCommit => 1} ); And here's a little extra, showing how to build connections for Access (via ADO), MSSQL (via ODBC), Sybase, and Oracle... my %dbDrivers = ("SYBASE" => "Sybase", "ORACLE" => "Oracle", "MSSQL" => "ODBC", "ACCESS9" => "ADO"); my $ConnStr = buildConn(); my $dbh; if ((uc($arg_db_type) eq "ACCESS2K")&&(uc($arg_db_type) eq "ACCESS97")) { $dbh = DBI->connect( $ConnStr, 'admin', {RaiseError => 1, AutoCommit => 1} ); } elsif (uc($arg_db_type) eq "SYBASE") { $dbh = DBI->connect( $ConnStr.";database=$arg_use_db", $arg_sysuser, $arg_syspwd, {RaiseError => 1, AutoCommit => 1} ); } elsif (uc($arg_db_type) eq "ORACLE") { $dbh = DBI->connect( $ConnStr, $arg_sysuser, $arg_syspwd, {RaiseError => 1, AutoCommit => 1} ); } # Build Connection String sub buildConn { my $retval = "dbi:". $dbDrivers{$arg_db_type}; if (uc($arg_db_type) eq "ORACLE") { $retval .= ":host=". $arg_connection .";sid=". $arg_use_db; } elsif (uc($arg_db_type) eq "SYBASE") { $retval .= ":server=". $arg_connection; }elsif (uc($arg_db_type) eq "MSSQL") { $retval .= ':driver={SQL Server};Server='. $arg_connection .';database='. $arg_use_db .';'; }elsif ((uc($arg_db_type) eq "ACCESS97") or (uc($arg_db_type) eq "ACCESS2K")) { $arg_syspwd = ''; # Need to set the password to NULL for Access.... $retval .= ":Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=". $arg_use_db .""; } return $retval; } > kevindot HTH, amonotod -- `\|||/ amonotod@ | sun|perl|windows (@@) charter.net | sysadmin|dba ooO_(_)_Ooo____________________________________ _____|_____|_____|_____|_____|_____|_____|_____|