Re: ASP cant connect to local SQL db but VB can with same code

From: Lance Wynn (lance_wynn_at_N.O.S.P.A.M.hotmail.com)
Date: 02/25/04


Date: Tue, 24 Feb 2004 20:23:19 -0700

Your code runs fine in ASP on my box (Same setup as yours).
The only way I could replicate the error was to rename the server parameter
to something that doesn't exist.
I have had a problem in the past where the NS name "localhost" didn't
actually resolve to 127.0.0.1 can you try this string?

sConn = "Driver={SQL
Server};uid=sa;pwd=MyPassword;server=(local);database=Northwind"

or

sConn = "Driver={SQL
Server};uid=sa;pwd=MyPassword;server=127.0.0.1;database=Northwind"

"ZLA" <anonymous@discussions.microsoft.com> wrote in message
news:FD52CD1A-E0D2-445A-8EFA-F54A784796D9@microsoft.com...
> I am running IIS 5.1 on Windows XP Professional with SQL Server 2000
Developer Edition, SP3. I also have Visual Basic 6, SP5. The VB project
references ADO 2.8 Recordset Library.
>
> I wrote the following code in a standard VB EXE which runs just fine:
>
> Dim sConn As String
> Dim sSQL As String
> Dim conn As New ADODB.Connection
> Dim rs As ADODB.Recordset
>
> sConn = "Driver={SQL
Server};uid=sa;pwd=MyPassword;server=localhost;database=Northwind"
> sSQL = "select * from orders where orderid = 10250"
>
> conn.Open sConn
> Set rs = conn.Execute(sSQL)
> If Not rs.EOF Then
> MsgBox rs("shipaddress")
> End If
> rs.Close
> Set rs = Nothing
> Set conn = Nothing
>
>
> I wrote the following code in an ASP page which yields an error:
>
> <%@ Language=VBScript %><%Option Explicit%><%
> dim Conn, RS, sConn, sSQL, sAddress
>
> sConn = "Driver={SQL
Server};uid=sa;pwd=MyPassword;server=localhost;database=Northwind"
> sSQL = "select * from orders where orderid = 10250"
>
> Set Conn = Server.CreateObject("ADODB.Connection")
> Conn.Open sConn
>
> Set RS = conn.execute(sSQL)
> if not rs.eof then
> sAddress = rs("ShipAddress")
> else
> sAddress = "Unknown Address"
> end if
> %><html><%=sAddress%></html>
>
>
> The error I get is as follows:
>
> Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
> [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or
access denied.
> /zladev/Defaultzeke2.asp, line 11
>
> Line 11 is the "Conn.Open sConn" statement.
>
> I have searched numerous boards and support groups and have been unable to
find anything that points me to the right solution to my problem.
>
> Because it works for VB but not for ASP, I assume the problem is due to
incorrect configuration of IIS, the web site or my firewall software (McAfee
Personal Firewall).
>
> I tried disabling the firewall software and tried various permissions and
option changes in IIS to get this to work but no luck.
>
> I hope someone can give me some useful suggestions or even a resolution.
>
> Thanks in advance.
>
> ZLA
>



Relevant Pages