Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

login to MSSQL via DBI::ODBC

by Deda (Novice)
on Sep 24, 2003 at 13:58 UTC ( [id://293853]=perlquestion: print w/replies, xml ) Need Help??

Deda has asked for the wisdom of the Perl Monks concerning the following question:

hi all, I am using this to login to my MSSQL2K server.
my $DSN = "driver={SQL Server};Server=$host;database=$table;UID=$uname +;PWD=$pwd;"; my $dbh=DBI->connect("dbi:ODBC:$DSN") || die "Error: $DBI::errstr";
This works fine, until i try to connect to a remote SQL server. The remote connection error string says "Microsoft\ODBC SQL Server Driver\SQL Server\Login failed for user '<MyDomain>\<MyUserName>'. (SQL-28000). Which indicates to me, that the $DSN string doesn't really make much difference ($uname and $pwd are not <MyDomain> and <MyUserName>). So i replaced the variable with:
my $DSN = "driver={SQL Server};Server=$host;database=$table;";
The results were the same: local login is OK, remote is not. I am running the scripts under my account, which is an ADMIN member on localhost, but is not on the remote machine, which is probbably why it's possible to access the local sql server. Has anyone got any ideas, why the login is not attempted with the varibles supplied in $DSN? I haven't found any other examples, that would use something other than the $DSN string shown here. 10x, Deda.

Replies are listed 'Best First'.
Re: login to MSSQL via DBI::ODBC
by olivierp (Hermit) on Sep 24, 2003 at 14:14 UTC

    I have experienced this on Win32 platforms with ActiveState Perl 5.8.0 when upgrading DBI to 1.3?

    For some reason, DBI is not taking into account the username & password specified in the DSN.

    However, the following works for me:

    my $dbh=DBI->connect("dbi:ODBC:$DSN", $uname, $pwd) || die "Error: $DB +I::errstr";
    HTH
    --
    Olivier

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://293853]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-18 20:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found