develooper Front page | perl.dbi.users | Postings from April 2007

Re: Is PERL --> MS SQL really that difficult?

Thread Previous | Thread Next
Peter J. Holzer
April 26, 2007 01:33
Re: Is PERL --> MS SQL really that difficult?
Message ID:
On 2007-04-25 17:24:40 -0400, Robert Denton wrote:
> Can't connect to data source driver={SQL Server};Server=<>; 
> database=<userFeedback>;uid=<testUser>; pwd=<testPass>;, no database driver 
> specified and DBI_DSN env var not set at ./ line 11
> $dbh = DBI->connect( $data_source, $username, $password );
> And my $data_source var is set to this:
> my $data_source = 'driver={SQL Server};Server=<>; 
> database=<userFeedback>
> ;uid=<testUser>; pwd=<testPass>;';
> As for the other part of the error, "no database driver specified", I am not 
> sure what else I need to do to make perl aware of the FreeTDS driver. I have 
> 'use DBI;' in the top of the script which is supposed to be sufficient.  In 
> otherword, I do not believe that I need to tell it to use DBD::ODBC.

Why do you believe that? How should DBI know that it is supposed to use
DBD::ODBC (and not DBD::Oracle, DBD::mysql, DBD::Sybase or whatever) if
you don't tell it? 

From "perldoc DBI":

           The $data_source value must begin with ""dbi:"driver_name":"".  The
           driver_name specifies the driver that will be used to make the con‐
           nection. (Letter case is significant.)

So for ODBC, it must start with "dbi:ODBC:". Assuming that the data
source you specified is correct for the ODBC driver, the complete
data source would then be
'dbi:ODBC:driver={SQL Server};Server=<>;database=<userFeedback>;uid=<testUser>;pwd=<testPass>;'.


   _  | Peter J. Holzer    | If I wanted to be "academically correct",
|_|_) | Sysadmin WSR       | I'd be programming in Java.
| |   |      | I don't, and I'm not.
__/   | |   -- Jesse Erlbaum on dbi-users

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About