in reply to connection issues to MS SQL Server

lsxo:

If your DB server supports database authentication, remove the "Trusted_Connection=False" bit from your connection string. If it's using windows authentication instead, then remove the "user=...;password..." bit, and pass in undef in the user and password parameters to the DBI->connect() function. That's what I use here ... successfully.

If you're running on *NIX box, I don't know what you may have to do to make a windows authentication work. But the normal database authentication will work.

...roboticus

Replies are listed 'Best First'.
Re^2: connection issues to MS SQL Server
by lsxo (Novice) on Aug 07, 2009 at 18:57 UTC
    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!!
      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.