Cannot open SQL Server from ASP page
am 04.08.2005 21:45:20 von medium.fisherHi
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
%>
<%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
%>