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

use strict; use DBI; $| = 1; my $server_name = 'rb_intra_sqldev'; my $database_name = 'RMBSAnalytics'; my $DSN = "DRIVER={SQL Server};Database=$database_name;Server=$server_ +name;uid=datapull;pwd=datapull"; my $dbh = DBI->connect("dbi:ODBC:$DSN", undef, undef) || die "Couldn't + open database: $DBI::errstr\n"; $dbh->disconnect();
is this what you were refering to? I'm sorry I'm just feeling really lost right now!!

Replies are listed 'Best First'.
Re^3: connection issues to MS SQL Server
by roboticus (Chancellor) on Aug 09, 2009 at 21:17 UTC
    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

      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.