Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cannot get DBI::ODBC to work with DSN & MS SQL

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Can someone help as to why when using the DBI::ODBC method to connect to a MS SQL server via a DSN it doesn't work?

If I use the Win32::ODBC module and the same DSN it works fine.

DBI errors as follows...
DBI connect('MYDSN:localhost','USERID,...) failed: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (SQL-IM002) at

the DBI statement looks like this..
Code:
my $db = DBI->connect("DBI:$DRIVER:$DSN:$HOST",$USER_ID,$PASSWORD ,{'RaiseError' => 1});

why is this happening, i can't work out what's wrong?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
It's ok I gave up with the DBI module and ODBC, I could get it to connect using DNS-Less connection string, but then the SQL commands didn't work.

It's far too much hastle to get DBI to run on Windows ActiveState perl, as even the DBD::ODBC module isn't installed as standard.

So I re-wrote my code to have a flag set,
if = mysql it uses DBI module
if = ODBC it uses the Win32::ODBC module.

Everything is now running fine!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top