Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Confused by DBI:ODBC Driver name

by poj (Abbot)
on Dec 23, 2011 at 22:00 UTC ( [id://944994]=note: print w/replies, xml ) Need Help??


in reply to Confused by DBI:ODBC Driver name

Try using a different string for the stored connection something like this

use strict; use DBI; print "Driver = $_\n" for DBI->data_sources('ODBC'); my $db_name = 'online_labs_gs'; my $db_type = 'MSSQL'; my %SERVER = ( MSSQL => { 'dsn' => 'DBI:ODBC:MS SQL 2005', 'user' => 'yyy', 'pwd' => 'yyy', }, MSSQL1 => { 'dsn' => "DBI:ODBC:driver={SQL Server};server=localhost;dbq=$db_n +ame", 'user' => 'yyy', 'pwd' => 'yyy', }, MySQL => { 'dsn' => "dbi:mysql:$db_name:localhost:3306", 'user' => 'xxx', 'pwd' => 'xxx', }, ); my $hr = $SERVER{$db_type}; my $dbh = DBI->connect($hr->{'dsn'},$hr->{'user'},$hr->{'pwd'}, {RaiseError => 1});
poj

Replies are listed 'Best First'.
Re^2: Confused by DBI:ODBC Driver name
by Generoso (Prior) on Dec 24, 2011 at 05:03 UTC

    Have you tested your DSN? Does it connect to the database?

      Yes I have. Using {SQL Server}, I can connect to the database and access things. I just wonder if the SQL Server driver manages to somehow make a connection by some knowledge it has of the system. So far, things work just fine using it vs. what I expect to use as the DSN on a local machine. It might be different connecting to remote server, but I haven't done that yet.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-26 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found