Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
LanaC
Starting Member
2 Posts |
Posted - 2004-07-15 : 09:37:15
|
Please help. I am at my wits end. I have SQL Server 2000 on a Windows 2003 server. I have my database on a Nmade Instance . Named Pipes is disabled and only TCP/IP is enabled. Authentication is set to Windows only. The server is in Active Directory.My web site is on a Windows 2000 server with IIS 5. I have installed the Client Network Utilities and set the alias to TCP/IP also. I can connect to the SQL server using the Query Analyzer.I have downloaded and installed ActiveState's ActivePerl 5.6.1.638-MSWin32-x86.msi on both machines. I have also installed DBI and DBD::ODBC on both machine. Both machine have MDAC 2.8 installed.The code I am using to connect is as follows:my $user = 'user';my $pass = 'password';my $db = "database";my $server = "servername\\instancename";my $ipadd = "xxx.xx.xx.xxx,xxxx";my $driver = '{SQL Server}';Option #1$DSN = 'driver=$driver;Server=$server;uid=$user;pwd=$pass;database=$db;network=DBMSSOCN;address=$ipadd;';$dbh = DBI->connect("dbi:ODBC:$DSN") or die 'Cannot Open SQL Server Database $DBI::errstr\n';Option #2$DSN = 'driver=$driver;Server=$server;uid=$user;pwd=$pass;database=$db';$dbh = DBI->connect("dbi:ODBC:$DSN") or die 'Cannot Open SQL Server Database $DBI::errstr\n';Option #3$dbh = DBI->connect('dbi:ODBC:driver=$driver:dsn',$user,$pass) or die 'Cannot Open SQL Server Database $DBI::errstr\n';Option #4$dbh = DBI->connect("dbi:ODBC:database=$db;server=$server",$user,$pass) or die '$DBI::errstr\n'; From all that I have read and from previous scripts I have written, any of these should work, but I am getting the following error.DBI connect('driver=$driver:dsn','user',...) failed: at C:\cgi-bin\CGI.pl line xxx Cannot Open SQL Server Database $DBI::errstr\n at C:\cgi-bin\CGI.pl line xxx. Where xxx = the line number of the connection call. All of my previous scripts have been written for forms where the web server(Apache), database(MySQL), and script(Perl CGI) are all on the same machine. I am not at all familiar with SQL Server, and am struggling to learn quickly. PLease and ideas would be greatly appreciated.Thank you LanaC |
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2004-07-15 : 10:35:33
|
try thismy $DSN = 'driver={SQL Server};Server=server_name; database=database_name;uid=user;pwd=password;'; my $dbh = DBI->connect("dbi:ODBC:$DSN") or die "$DBI::errstr\n"; Also, you might want to check that you can actually make an ODBC connection to the database from the 'Data Sources' control panel. -ec |
|
|
LanaC
Starting Member
2 Posts |
Posted - 2004-07-15 : 14:22:57
|
I can make a connection from the data sources screen. I tried the my $DSN = 'driver={SQL Server};Server=server_name; database=database_name;uid=user;pwd=password;'; my $dbh = DBI->connect("dbi:ODBC:$DSN") or die "$DBI::errstr\n";and got a slightly different error: DBI connect('driver={SQL Server};Server="Server_name"; database="database_name";uid="user";pwd=password;','',...) failed: at C:\cgi-bin\CollaborationCGI.pl line 156 [Microsoft][ODBC SQL Server Driver][DBNETLIB]Specified SQL server not found. (SQL-08001) [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). (SQL-01000)(DBD: db_login/SQLConnect err=-1)LanaC |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-07-15 : 14:26:41
|
DBNETLIB means you are using named pipes to connect to the database server. It would say DBMSSOCN if it were TCP/IP. The alias that you created, are you referring to it in the connection string? They must be the same. Does the alias specify the correct SQL Server port?Tara |
|
|
|
|
|
|
|