in reply to Re^2: connection issues to MS SQL Server
in thread connection issues to MS SQL Server

lsxo:

More like this:

my $server_name = 'rb_intra_sqldev'; my $database_name = 'RMBSAnalytics'; my $user_name = 'datapull'; my $password = 'datapull'; my $DSN = "DRIVER={SQL Server};Database=$database_name;Server=$server_ +name"; my $dbh = DBI->connect("dbi:ODBC:$DSN", $user_name, $password) or die "Couldn't open database: $DBI::errstr\n";
...roboticus

Replies are listed 'Best First'.
Re^4: connection issues to MS SQL Server
by mje (Curate) on Aug 11, 2009 at 09:33 UTC

    JFYI There is little difference between passing the user/pass on the DBI connect call and putting it in the connection string IF the connection string contains DSN= or DRIVER=. What DBD::ODBC does is look for a DRIVER= or DSN= and if they are missing it calls SQLConnect first (for backwards compatibility) with the connection string, username and password. If SQLConnect fails or connection string contained DRIVER/DSN it appends the username/password passed in DBI->connect call to the connection string (unless the connection string already contains UID/PWD) and passes the resulting string to SQLDriverConnect.