Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Can I set the DSN for an ODBC connection?

by legato (Monk)
on Feb 17, 2005 at 19:46 UTC ( [id://432058] : note . print w/replies, xml ) Need Help??


in reply to Can I set the DSN for an ODBC connection?

use Win32::ODBC; print "Add DSN successful" if add_dsn('TestDSN'); sub add_dsn { my $dsn = shift; my $result = Win32::ODBC::ConfigDSN( ODBC_ADD_DSN, "SQL Server", ## this last is the driver name ( ##options "DSN=$dsn", ## DSN identifier "NETWORK=DBMSSOCN", ## use TCP/IP library "SERVER=test_server", ## server name "DATABASE=test_db", ## database name "DESCRIPTION=My test DSN" ) ); ## end of ConfigDSN call unless ($result) { print STDERR "Couldn't create $dsn because of error: " .Win32::ODBC::Error()."\n"; return undef; } return 1; } #^^ add_dsn
This code tested on Win NT,95,98,2k,2k3,XP with ActiveState Perl 5.8.6

Anima Legato
.oO all things connect through the motion of the mind