Asp – get an ADO connection error while using classic ASP

adoasp-classic

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

Best Answer

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.

Related Topic