Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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)...

Replies are listed 'Best First'.
Re: Using trusted connection to MS SQL (blanks)
by tye (Sage) 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!
Re: Using trusted connection to MS SQL
by jfroebe (Parson) on Mar 11, 2008 at 19:13 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://673578]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2018-03-20 20:34 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (259 votes). Check out past polls.