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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dsn less connection problems

Status
Not open for further replies.

vindi

Programmer
Dec 2, 2002
10
US
Hi all, I'm trying to set up a dsnless connection to SQL Server using the following code

use DBI;
my $DSN = 'driver={SQL Server};Server=LAB135_20143;database=test;uid=xxx;pwd=xxx;';
my $dbh = DBI->connect('DBI:ODBC:$DSN') # quit if not able to connect
or die "Fatal Error: Couldn't connect to database: . DBI->errstr";


I keep getting this error message

DBI->connect($DSN) failed: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (SQL-IM002)(DBD: db_login/SQLCo
nnect err=-1) at dsnless.pl line 3

This seems to be the correct syntax for setting up a dsnless connection but it doesnt seem to be working. Also, I would like to point out, I also currently have a system DSN set up dor that database.

Someone please help.
 
Check that the driver name you listed in $DSN is verbatim what it is in ODBCAD32's listing. To give an idea, this is one I used before with Access (even has the *.mdb in there, don't know if it's required, but wth):
Code:
my $DSN = 'driver=Microsoft Access Driver (*.mdb);dbq=HClub.mdb';

----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
If i check out the listing in ODBC sources under administative tools in the control panel it says "SQL Server". Also the driver is SQLSRV32.dll which i think is correct. I even installed MDAC and it still doesnt work. I tried using the IP address of the server, along with the port number and I get the same error. Is there something i'm missing. I have the DBI and DBD-ODBC packages installed. Does the server need to have any settings?
someone please help me out. I desparately need this to work. I have to run a shared PERL script over a network and I cannot go about making DSN's on each computer.
 
You said you don't want to have to create the DSN for that database on every client machine, but does every client machine have the SQL Server ODBC driver installed? I know I don't have it, but it might be a standard on your network.

Other than that, I'd say read the DBD::ODBC documentation, but from your $DSN above, it certainly looks like you did exactly that. This might be better put in a MSSQL or Windows Server forum (create a post there and include a link back to here) as it's sounding less and less like a Perl problem. I'm not trying to pawn off your problem, they just know more about SQL Server than we do.

Best of luck,
Andrew

----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top