views:

537

answers:

2

Hi guys, I am getting an error when running this classic asp script:

Dim DB_CONNECTIONSTRING, rs, iRecordCount, strSQL

DB_CONNECTIONSTRING = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=employee;Trusted_Connection=yes;"
strSQL = "SELECT * FROM EmployeeProfiles"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, DB_CONNECTIONSTRING, adOpenStatic, adLockReadOnly, adCmdText

The message I am getting is (the server does exsist):

Microsoft OLE DB Provider for SQL Server error '80004005'

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

\Default.asp, line 13

+1  A: 

Either the server you're running the ASP on doesn't have a running database server, or the database server should have an instance name. One common mistake is to forget to add the SQLEXPRESS instance name for SQLExpress installs.

Jacob
I am not using SQLExpress. I am using localhost
Csharp
+1  A: 

I see you're using Trusted_Connection=yes in your connection string. That means that whatever identity ASP is running under will try to connect to the database server using Windows authentication. The actual identity the web server uses depends on the platform and setup (usually IUSR_Foo).

To test out if this is the issue, try using temporarily replacing the connection string with one that uses SQL authentication. If this is the issue, you may want to either configure the web server to run the ASP under a different user account which has been granted database access (preferred) or give the current web server's identity access to the database. Or you can stick with SQL authentication, of course.

Jacob