Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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.

    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?
[marto]: hey Corion, good weekend?
[prospect]: Thank you
[marto]: no problem prospect
[Corion]: I hope you all spent a good weekend!
[Discipulus]: good morning eumonks!
[Discipulus]: yes thanks, mostly at seaside, but the waterpolo tournemts went bad, very bad.. ;=(
[marto]: hey Discipulus, Corion a reasonable weekend. The boys first trip to the cinema
[Corion]: Discipulus: You got pushed too much under water?
[Corion]: marto: Oooh - cinema... I guess that's something I could do with my godson and sibling and sister as well, but I guess that getting a six year old and two four year olds into one movie is a tough sell ;)
[marto]: busy weekend, no me time :P

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2017-07-24 08:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (348 votes). Check out past polls.