Cannot open SQL Server from ASP page

Cannot open SQL Server from ASP page

am 04.08.2005 21:45:20 von medium.fisher

Hi

I have an asp page running on my Windows XP Pro PC at home. I have a
virtual directory setup in iis. ASP files run ok, but I am trying to
access a remote SQL Server database hosted by an ISP. The message I
get is:

Microsoft OLE DB Provider for SQL Server (0x80004005)
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or
access denied

I can run the same ASP file on my pc at work and I can access the SQL
Server database. The ASP code is below, with the connection details
changed for security reasons.

Any ideas?

Thanks


<%
Option Explicit
%>


SQL Server Test


<%ShowSQLServer%>



<%
Sub ShowSQLServer

dim cn
dim rs
dim sConnect

sConnect = "Provider=SQLOLEDB;Data Source=1.2.3.4;" _
& "User ID=abc;Password=pass123;" _
& "Initial Catalog=companydb;"

Set cn=Server.CreateObject("ADODB.Connection")
Set rs=Server.CreateObject("ADODB.RecordSet")
cn.Open sConnect
rs.Open "SELECT StaffForename FROM tblStaff", cn

response.write "---------------
"

do while not rs.eof
response.write rs("StaffForename") & "
"
rs.movenext
loop

rs.Close
cn.Close

set rs = Nothing
set cn = Nothing
End Sub
%>

Re: Cannot open SQL Server from ASP page

am 04.08.2005 22:44:24 von reb01501

m.fisher@uku.co.uk wrote:
> Hi
>
> I have an asp page running on my Windows XP Pro PC at home. I have a
> virtual directory setup in iis. ASP files run ok, but I am trying to
> access a remote SQL Server database hosted by an ISP. The message I
> get is:
>
> Microsoft OLE DB Provider for SQL Server (0x80004005)
> [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or
> access denied
>

Have you seen this article?
http://www.aspfaq.com/show.asp?id=2009

Make sure you read it thoroughly and follow any links to KB articles that
may be relevant.

Bob Barrows
PS. You may need to explicitly specify that the connection needs to use
tcp/ip on your home machine. Try specifying the Network Library attribute
per the connection string samples at www.carlprothman.net
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.