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

Re: Connection to DataBase

by nikosv (Hermit)
on Sep 14, 2010 at 18:05 UTC ( #860127=note: print w/ replies, xml ) Need Help??


in reply to Connection to DataBase

From the DSN part of your question I gather that you've been using ODBC and you had to set the DNS up.

With DBI you do not have to do that.Just use the server name straight up(if you have made the correlation to it's ip address inside the client's host file,so it is able to look it up)and the database name

As marto suggests look up the DBI docs.


Comment on Re: Connection to DataBase
Re^2: Connection to DataBase
by Jenda (Abbot) on Sep 14, 2010 at 23:06 UTC

    In this particular case the docs of DBD::ODBC will be more instructive.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

Re^2: Connection to DataBase
by Anonymous Monk on Sep 15, 2010 at 15:49 UTC

    You can use DBD::ADO or DBD::ODBC to connect to SQL Server 2008 databases, if you use DBD::ODBC you may google for "DSN less connection", this is what you need. Using BDB::ADO the connection should look like:

    my $userid = q{}; my $password = q{}; my $strCnn = "Provider=SQLOLEDB; Data Source=$Servername; Initial +Catalog=$Tablename; Integrated Security=SSPI;"; $dbh = DBI->connect( "dbi:ADO:$strCnn", $userid, $password, { Rais +eError => 1, AutoCommit => 0 } ) or croak "Cannot connect: $DBI::errstr";

    but beware, there is a problem: SQLOLEDB may truncate inserted strings. Look at the docs of DBD::ADO.

    If you use DBD::ODBC the connection should look like:

    my $data_source = qq/dbi:ODBC:driver={SQL Server};Server=$Serverna +me;database=$DataBaseName;Regional=No;/; my $user = q//; my $password = q//; $dbh = DBI->connect($data_source, $user, $password) or die "Can't connect to $data_source: $DBI::errstr";

    Hope that helps.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2014-09-01 19:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (16 votes), past polls