inetserver asp db:
I have an ASP file (shown below) which I call from an HTM page to query a
database table. It works correctly if I pass it the correct connection
string. I am trying to make it fail with a proper error message if I change
the UserID value in my connection string to a non-existing user (as an
example). Therefore, it should fail on the conn.Open line and give me some
sort of connection error message in Err.Description. But I get an "Operation
is not allowed when the object is closed" message which sounds like it is
coming from a line which runs after the conn.Open line. I tried commenting
everything between the conn.Open line and conn.Close line and I still receive
the same message. If I comment out the conn.Close line, the ASP file fails
all together on the xml.Send() line in the HTM page.
I tried to put an [if Err.Number <> 0 then] line right after the conn.Open
line, but the ASP file fails altogether when I do that.
Any ideas which line is producing the error message and how I can get a
proper error message from the conn.Open line?
Thanks,
Bill
-----------------------------------------------------------
// THIS IS PART OF MY WebLogin.htm FILE USING JAVASCRIPT.
var xml = new ActiveXObject("Microsoft.XMLHTTP");
xml.Open( "GET", "WebLogin.asp", false );
xml.setRequestHeader('ConnectionString', sConnect);
xml.setRequestHeader('Username', f.LogNamTbx.value);
xml.setRequestHeader('Password', f.PasswdTbx.value);
xml.setRequestHeader('TablePrefix', sTablePrefix);
xml.Send();
try {eval(xml.responseText);}
catch(e){if(e instanceof Error) {alert("Error encountered when evaluating
the [WebLogin.asp] page. Error message: " + e.message)}}
if (f.Result2.value != "")
alert("Error: " + f.Result2.value);
-----------------------------------------------------------
<%
' THIS IS MY WebLogin.asp FILE USING VBSCRIPT.
' Turn On Error Handling
On Error Resume Next
dim sUser
dim sPwd
dim conn
dim rs
dim success
dim sTblPrefix
dim sConn
dim FName
dim LName
dim sEmail
dim errormsg
errormsg = ""
success = false
sConn = Request.ServerVariables("HTTP_ConnectionString")
sUser = Request.ServerVariables("HTTP_Username")
sPwd = Request.ServerVariables("HTTP_Password")
sTblPrefix = Request.ServerVariables("HTTP_TablePrefix")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open sConn
Set rs = conn.Execute("SELECT First_Name, Last_Name, Email, Password FROM "
& sTblPrefix & "CT_LOGON_NAMES WHERE Name = '" & sUser & "'")
if not rs.eof then
if rs("Password") = sPwd then
success = true
FName = rs("First_Name")
LName = rs("Last_Name")
sEmail = rs("Email")
end if
rs.close
end if
conn.Close
Set conn = Nothing
' Error Handler
if Err.Number <> 0 then
success = false
'errormsg = Err.Number & " - " & Err.Source & " - " & Err.Line & " - " &
Err.Description
errormsg = Err.Number & " - " & Err.Source & " - " & Err.Description
end if
%>
var ele;
ele = document.getElementById("Result");
ele.value = "<%=success%>";
ele = document.getElementById("Result2");
ele.value = "<%=errormsg%>";
ele = document.getElementById("FirstName");
ele.value = "<%=FName%>";
ele = document.getElementById("LastName");
ele.value = "<%=LName%>";
ele = document.getElementById("RequestorsEmailAddress");
ele.value = "<%=sEmail%>";