MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 15th, 2004, 09:42 AM
LanaC LanaC is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 LanaC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Problems connecting to SQL Server DB using Perl CGI

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 any ideas would be greatly appreciated.
Thank you

LANAC

Reply With Quote
  #2  
Old July 15th, 2004, 03:21 PM
dcaillouet's Avatar
dcaillouet dcaillouet is offline
Big Endian
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2001
Location: Fly-over country
Posts: 1,173 dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 16 h 29 m 5 sec
Reputation Power: 24
The thing that I noticed in your post was "Authentication is set to Windows only." When integrated security is used, you don't enter a UserId/Password combination in the connect statement since the authentication is coming from Active Directory.

If possible you might want to set your database to mixed security and try connecting using a UserId/Password. If you can get that to work, then set it back to "Windows Only" and see if you can get Integrated Security to work. This might help you isolate whether the problem was the syntax of your connect statement or your connectivity to Active Directory authentication that is causing a problem. Since the error message doesn't return a message from SQL Server, it looks like you currently have a syntax error of some kind. But I'm not much of a Perl guru so I can't tell.

Read the following link and see if it has anything useful in it. You'll notice they explicitly mention Integrated Security and leave off the UserId/Passwords in their connects:

http://www.experts-exchange.com/Dat...Q_20889697.html

I wish I could be more helpful, but like you, I've never used Perl to connect to SQL Server.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Problems connecting to SQL Server DB using Perl CGI


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT