Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Connection to DataBase

by nikosv (Chaplain)
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.

Replies are listed 'Best First'.
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.

    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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://860127]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2017-09-26 02:37 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (291 votes). Check out past polls.