Solved

Problem getting connection string to SQL Server 2005 to work in asp

Posted on 2006-07-04
20
305 Views
Last Modified: 2010-08-05
Ive installed SQL Server 2005 on my local machine and am testing a site locally within IIS.

My connection string is

oDB.Open "driver={SQL Server};server=<Local IP>;database=DBName;Network=dbmssocn", "", ""

I currently dont have SQL Server passwords assigned to the database and so want to use Windows permissions to access it. Can someone please tell me what Im doing wrong as currently Im just getting

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]SQL Server does not exist or access denied.

Cheers
0
Comment
Question by:digital_soul
  • 11
  • 8
20 Comments
 
LVL 23

Expert Comment

by:apresto
ID: 17036470
try this string instead:

Provider=SQLNCLI;Server={server};Database={db};Trusted_Connection=yes;"
0
 
LVL 23

Expert Comment

by:apresto
ID: 17036473
0
 
LVL 2

Author Comment

by:digital_soul
ID: 17036610
This isnt working either. What exactly should I put for the {server}? If I use my local computers IP address as provided by an online IP check then I get the following error:

Microsoft SQL Native Client (0x80004005)
Named Pipes Provider: Could not open a connection to SQL Server [53].

If I use my Computer Name then I get:

Microsoft SQL Native Client (0x80040E4D)
Login failed for user 'D6B5732J\IUSR_D6B5732J'.

cheers
0
 
LVL 23

Expert Comment

by:apresto
ID: 17036674
server should be the Ip address or the computer name/(Local)
0
 
LVL 2

Author Comment

by:digital_soul
ID: 17036723
Ok well its not working so any ideas why this might be

Connection string in full:

"Provider=SQLNCLI;Server=D6B5732J;Databaserad;Trusted_Connection=yes;"

error:

Microsoft SQL Native Client (0x80040E4D)
Login failed for user 'D6B5732J\IUSR_D6B5732J'.
0
 
LVL 2

Author Comment

by:digital_soul
ID: 17036725
sorry that was meant to be:

"Provider=SQLNCLI;Server=D6B5732J;Database=rad;Trusted_Connection=yes;"
0
 
LVL 23

Expert Comment

by:apresto
ID: 17036775
ok, try this:

Provider=SQLNCLI;Server=localhost;Database=rad;Trusted_Connection=yes;
0
 
LVL 2

Author Comment

by:digital_soul
ID: 17036794
still getting:

Microsoft SQL Native Client (0x80040E4D)
Login failed for user 'D6B5732J\IUSR_D6B5732J'.

0
 
LVL 23

Expert Comment

by:apresto
ID: 17036812
Go to SQL Enterprise Manager -> Your Server -> Your DataBase -> Users

Right Click 'Users' and Add New Database user
Login Name: & User Name: D6B5732J\IUSR_D6B5732J (Give db_datareader & db_datawriter access atleast)

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21401963.html?query=Login+failed+for+user+IUSR&clearTAFilter=true
0
 
LVL 2

Author Comment

by:digital_soul
ID: 17036839
Still getting the same error even after doing that
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Author Comment

by:digital_soul
ID: 17037166
Does noone have any ideas? All I want to do is open a connection to my local SQL Server 2005 database!

Stu
0
 
LVL 23

Expert Comment

by:apresto
ID: 17037181
ok, open query analyser, and connect, what username and password do you use, or are you using windows?
0
 
LVL 2

Author Comment

by:digital_soul
ID: 17037209
Im using Windows Authentication. I can create a System DSN and connect to the database that way, but even when I attempt to create a connection from my ASP page via that DSN I still get the same error of Login failed for user 'D6B5732J\IUSR_D6B5732J'.

0
 
LVL 23

Expert Comment

by:apresto
ID: 17037232
ok, just so we know everything is ok, would you create a user - or try logging in with your sa account
0
 
LVL 2

Author Comment

by:digital_soul
ID: 17037255
ok, I have no idea what my sa account is. I dont recall ever setting any pasword for a SQL sa account and I dont now know how to switch to SQL Server authentication.

The user IUSR_D6B5732J that is failing to log on is the name for the Internet Guest Account on my local machine

The name of my database server appears to eb D6B5732J (SQL Server 9.0.1399 - D6B5732J\Stewart Caig)

Im not sure what other information would be pertinant to resolving this
0
 
LVL 23

Expert Comment

by:apresto
ID: 17037305
Its failing to log on because a user doesnt exist for this user does it - your connection string does not say anything about a user or password so i dont know why it is trying to log on with one - i am looking into it now
0
 
LVL 2

Author Comment

by:digital_soul
ID: 17037365
Would it not by default attempt to connect via the Internet Guest Account as that is effectivly the account that is being used by me via the browser. You'll have to excuse me, I dont have a great knowledge of how these things work, but it seems logical that the guest account would need to be given permission to access the SQL Server database? I may be well off with this, but im just not sure where else to start looking.
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 50 total points
ID: 17037413
You appear to have you SQL Server configured for Windows Login and if you are accessing it from a (i'm guessing) ASP page then, as you correctly mentioned, it wil be trying to connect using the IUSR account which, by default, will not have permissions to access the database.

You either need to go into your SQL Server and add IUSR to the Logins, or enable Mixed Mode authentication and pass a user/password as part of the connection string.
0
 
LVL 2

Author Comment

by:digital_soul
ID: 17037445
Hi Carl

Cheers. Could you explain how I do either of these options. I'm using the SQL Server 2005 Management Studio

cheers
0
 
LVL 2

Author Comment

by:digital_soul
ID: 17037461
Bingo! Cheers. I added the Internet Guest Account as a login and it now works. many thanks to both Carl and apresto for your help, but points go to carl
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now