neronikita
Technical User
I am trying to connect my ASP page to a SQL Server database. The page will not display, so I am assuming that it isn't getting a connection. I set up the DSN in my Datasources and tested it using the test button and that works. I'm wondering if the problem is that my DSN is set up on the computer I am using and the ASP page is sored on a different server where the SQL database is. That is running Server 2008 and SQL Server Standard. I just get a generic message, nothing that tells me what the problem is. I've worked with ASP in the past, but never had to create my own connection. Other non-database ASP pages do run. Any ideas? My code is below that I'm using just to test the connection.
TIA,
Di
<%@LANGUAGE="JAvaSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<%
Option Explicit
Response.Expires = 0
Dim objConn, objRS, strQuery
Dim strConnection
Set objConn = Server. CreateObject("ADODB. Connection")
strConnection = "DSN=ESI; Database=ESI; "
strConnection = strConnection & "UID=; PWD=; "
objConn. Open strConnection
strQuery = "SELECT empid, lastname FROM Employee "
strQuery = strQuery & "ORDER BY empid"
Set objRS = objConn. Execute(strQuery)
%>
<HTML>
<BODY>
All Employee IDs with Last Name: <BR><BR>
<%
While Not objRS. EOF
Response. Write obj RS("empid") & " ("
Response. Write objRS("lastname") & ") <BR>"
obj RS.MoveNext
Wend
objRS. close
objConn. close
Set objRS = Nothing
Set objConn = Nothing
%>
</body>
</html>
TIA,
Di
<%@LANGUAGE="JAvaSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<%
Option Explicit
Response.Expires = 0
Dim objConn, objRS, strQuery
Dim strConnection
Set objConn = Server. CreateObject("ADODB. Connection")
strConnection = "DSN=ESI; Database=ESI; "
strConnection = strConnection & "UID=; PWD=; "
objConn. Open strConnection
strQuery = "SELECT empid, lastname FROM Employee "
strQuery = strQuery & "ORDER BY empid"
Set objRS = objConn. Execute(strQuery)
%>
<HTML>
<BODY>
All Employee IDs with Last Name: <BR><BR>
<%
While Not objRS. EOF
Response. Write obj RS("empid") & " ("
Response. Write objRS("lastname") & ") <BR>"
obj RS.MoveNext
Wend
objRS. close
objConn. close
Set objRS = Nothing
Set objConn = Nothing
%>
</body>
</html>