Link to home
Start Free TrialLog in
Avatar of digital_soul
digital_soul

asked on

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

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
Avatar of apresto
apresto
Flag of Italy image

try this string instead:

Provider=SQLNCLI;Server={server};Database={db};Trusted_Connection=yes;"
Avatar of digital_soul
digital_soul

ASKER

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
server should be the Ip address or the computer name/(Local)
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'.
sorry that was meant to be:

"Provider=SQLNCLI;Server=D6B5732J;Database=rad;Trusted_Connection=yes;"
ok, try this:

Provider=SQLNCLI;Server=localhost;Database=rad;Trusted_Connection=yes;
still getting:

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

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)

https://www.experts-exchange.com/questions/21401963/Login-in-failed-for-user-'SKYNET-IUSR-SKYNET.html?query=Login+failed+for+user+IUSR&clearTAFilter=true
Still getting the same error even after doing that
Does noone have any ideas? All I want to do is open a connection to my local SQL Server 2005 database!

Stu
ok, open query analyser, and connect, what username and password do you use, or are you using windows?
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'.

ok, just so we know everything is ok, would you create a user - or try logging in with your sa account
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
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
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.
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Carl

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

cheers
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