1
votes

I am setting up an existing application on a new server. It is a mix of Asp.Net and Classic Asp pages. The asp.net pages work perfectly, but the classic asp pages give the following error:

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

My Settings:

  • Windows Server 2008 x64
  • IIS7
  • SQL 2008 Express with Advanced Services
  • 32bit application

Here are some things I've tried:

  • Set IIS7 AppPool to enable 32-bit applications
  • Enabled "Active Server Pages" extension in IIS "ISAPI and CGI Restrictions"
  • Installed Frontpage 2002 Extensions for IIS7 (from RTR)
  • Enabled Named Pipes protocol in SQL Config Mgr

My Connection String:

connectionString="Data Source=(local);Initial Catalog=System;Persist Security Info=True;User ID=System;Password=mypassword" providerName="System.Data.SqlClient"

My CLICONFG Alias:

  • Server Alias = System
  • Network Library = Named Pipes
  • Connection Parameters = (local)

I've successfully installed the program in this environment before without any issues. Both *.asp and asp.net are using the same connection string, so I can't see how that is a problem. The User "System" specified in the Connection String is setup as a user in SQL with all permissions granted.

Please help!! I've spent over 3 days on this.

Thanks!

4

4 Answers

0
votes

I'm not so sure that classic asp understands all the parameters in your connection string. It likely ignores something it doesn't understand but the on that I think it's having the greatest trouble with is this one:

Data Source=(local)

and possibly

providerName="System.Data.SqlClient"

I would try either:

  1. Creating a second connection string and use one for classic ASP and the other for aspx. Use this 'simple' format for classic asp:

    Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;
    
  2. Change the Data Source parameter to use the actual server or instance name.

0
votes

System.Data.SqlClient is a data provider for asp.net, it wouldn't work with classic asp.

Here's an example of a Classic ASP connection string for SQL Server

Provider=sqloledb;Data Source=yourServerAddress;Initial Catalog=yourDataBase;User Id=yourUserid;Password=yourPwd;

For more examples see here - look at oledb providers.

http://www.connectionstrings.com/sql-server/

Also, where are you putting your connection string? If it's in web.config then .net will be able to read it but Classic ASP won't. It needs to go in the page which wants to connect itself, in an include or in global.asa

Edit - one extra point. If you're using SQL Server Express then you need to specify this - eg:

Data Source=localhost\SQLEXPRESS
0
votes

Shawnda, John and Evan make good suggestions and points.

I'll share my active live server configurations with you so you have something to test on your server. That's if you're running MSSQL on IIS 7.x and Windows 2008 Server with any flavor of SQL Server 2008.

I run 2 servers mixed .Net and ASP one Web 2008 and 2008 R2 with IIS .Net sites with ASP using a common db all sites mixed work just fine.

First tip, make your connection string a Call Function or Sub. From what you said you have to find all the locations you have your connection string.

How we migrate will help you. Create your function and place it into your SQL Included pages or your master scripts page that is included in all pages that need your connection string.

Function ConnOpen(SqlConn)
Dim strConnSql
Set SqlConn = Server.CreateObject("ADODB.Connection")
strConnSql = "Provider=SQLNCLI10;Server=SERVERNAME\SQLEXPRESS;Database=DBNAME;UID=USER;PWD=PASSWORD;"
SqlConn.Open strConnSql
End Function

Function ConnClose(SqlConn)
SqlConn.Close
Set SqlConn = Nothing
End Function

Follow what has been suggested and change the string. This is how I migrate sites from databases. I will add a new connection string as a function and test it on one of my pages. If the new connection works I'll do a search and replace of the string. Once you figure out which connection string works you're going to stop spending time like 3 days.

The string above is active on my .Net sites in my inc_sqlpage.asp which is included in all pages that require database connection.

You should find all your connection strings and remove and replace them with a easier to manage function.

Call ConnOpen(MyConn)
... 'your SQL 
Call ConnClose(MyConn)

If after this method you still can't connect then I'll say it's your server naming or firewall if this is a new server.

Example: I do not use IP address connections only internal DNS machine names. If i changed the servername to IP I would see the same type of error. I'm sure you have tried different settings but try the one above switching IP with Machine Name, .\ and localhost but not (local).

0
votes

I found the solution!!!

Thanks everyone for your assistance. I finally found the solution!

Turns out the connection string for my classic asp pages were expecting SQL to be installed with the default instance....but I had done a named instance. The connection string had "Data Source = System" (System was an alias setup on the computer that only specified (local) as the connection....it did not specify the instance name.).

I changed the connection string to "Data Source = .\SQLEXPRESS" and it worked fine.

The connection string that was in there would have worked fine if I had selected "Default Instance" during the installation....as had been done on other servers I had installed.

Thanks again!