Easysoft
ODBC Drivers for Oracle, SQL Server, Firebird, ISAM, InterBase, Sybase, MS Access & more.

Easysoft ODBC-ODBC Bridge

How can I put attributes other than the DSN in my Perl DBI->connect call?

Article : 00085
Last Reviewed : 19th July 2005
Revision : 1

From DBD::ODBC 0.21, you can put all of the connection attributes specified in your odbc.ini file in the connection string passed to DBI->connect().

For example, suppose your odbc.ini file looked like this:

[dsn_name]
ServerPort = demo.easysoft.com:8888;
LogonUser = fred
LogonAuth = password
TargetDSN remotedsn

You can do away with the entire odbc.ini file and use the following Perl instead:

my $DSN = 'DRIVER={OOB};ServerPort=demo.easysoft.com:8888;';
$DSN = $DSN . 'LogonUser=fred;LogonAuth=password;TargetDSN=remotedsn';

my $dbh = DBI->connect("dbi:ODBC:$DSN",
                       "database_user",
                       "database_password")
          || die "Database connection failed: $DBI::errstr";

This can be particularly useful if you want to hide your usernames and password. For example, if you do not want them visible in the odbc.ini file. You could retrieve the username and password from somewhere else or even prompt for them.

Applies To

Knowledge Base Feedback

* Did this content help you?
Yes
No
Maybe
 
* Please select one option based on your first choice:
I'm very satisfied
I think it will help, but I haven't tried it yet
It is helpful, but I need more information
It is helpful, but hard to understand
Seemed relevant in search results, but didn't help me
The information is incorrect
The page contains one or more broken links
 
  Suggest new content or let us know how we can improve this content:

 
  (* Required Fields)   



© 1993 - 2008 Easysoft Limited. All rights reserved.