Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Using trusted connection to MS SQL

by johnmc (Novice)
on Mar 11, 2008 at 18:34 UTC ( #673578=perlquestion: print w/ replies, xml ) Need Help??
johnmc has asked for the wisdom of the Perl Monks concerning the following question:

Tried to find this answer within Perlmonks and in the interwebs with the search "perl trusted connection"
I throw myself on the mercy of this assemblage...

How do I use a trusted connection to an MS SQL server so I don't have to feed username/password ?

I am currently using:
use DBI; $dbh = DBI->connect('dbi:ODBC:'.$dbsrvr, $dbuser, $dbpass);
$dbsrvr = server name
$dbuser = SQL username
$dbpass = SQL password

Thanks in advance any and all help (or abuse)...
J

Comment on Using trusted connection to MS SQL
Download Code
Re: Using trusted connection to MS SQL
by jfroebe (Vicar) on Mar 11, 2008 at 19:13 UTC
Re: Using trusted connection to MS SQL (blanks)
by tye (Cardinal) on Mar 11, 2008 at 19:57 UTC

    Just leave off the username and password.

    my $dbh= DBI->connect( "dbi:ODBC:Driver=SQL Server;Server=$dbsrvr", '', '', { RaiseError => 1, PrintError => 0, ... }, );

    - tye        

Trusted connection to MS SQL using ODBC
by Narveson (Chaplain) on Mar 11, 2008 at 20:09 UTC

    Or use a Data Source Name. That's a Windows thing—try Control Panel, Administrative Tools, Data Sources (ODBC). Then

    $dbh = DBI->connect("dbi:ODBC:$DSN");

    The advantage is that you don't have to hardcode the connection details. If the server name should ever change on you, you can change your DSN, instead of hunting down all the references to it in your Perl code.

      Thanks everyone for putting up with my incomplete posting and giving their advice. I did leave out that I am working in a Windoze environment and connecting to a MSSQL database.... Anyway, it was as defining an ODBC connection in ControlPanel and using a DBI->connect. So thanks for the mind-reading and feel free to let me know of the deficiencies of any future posts!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2014-11-23 15:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (132 votes), past polls