Welcome to WebmasterWorld Guest from 54.198.185.204

Forum Moderators: ocean10000

Message Too Old, No Replies

Help with ADODB Query to Access in ASP

Error 800A0401

     
7:21 pm on Jan 30, 2005 (gmt 0)

New User

10+ Year Member

joined:Jan 30, 2005
posts:3
votes: 0


Can someone find the error here which is reported on line 21, this is bugging me. I had to move the top level of the web site up from the /www root and eliminate this folder altogether, flattening everything, due to my web hosting service not knowing how to use their IIS manager.

This is the line reporting the error:
Rs.ActiveConnection = "FILEDSN=&session("dataLocation")&"christiansf_TheData.dsn"

Here is the code:

<%@ Language=VBScript %>
<%

UserName = Request.Form("login")
Password = Request.Form("password")
if ( Username = "" or Password = "") then
Response.Redirect "login.htm"
end if

'Set conn = Server.CreateObject("ADODB.Connection")
'conn.Open(Application("jamesmhill_ConnectionString"))
'conn.Open "FILEDSN=E:\Web\christiansf\_database\christiansf_TheData.dsn"
'sql = "select * from data"
strQuery = "SELECT * FROM UFC_Users_Table " &_
"WHERE userName = '" & UserName & "' AND " &_
"password = '" & Password & "'"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "FILEDSN="&session("dataLocation")&"christiansf_TheData.dsn"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.ActiveConnection = "FILEDSN=&session("dataLocation")&"christiansf_TheData.dsn"
Rs.Open strQuery, Conn, 3, 3

If(Conn.State = 1) Then
'1 - State Open, 0 - State Closed
'This is what we do if we opened okay
'Construct a query


set rs = conn.Execute(strQuery)
if(rs.EOF or (Err.number > 0)) then
'Failed to log in
%><HTML>
<BODY bgcolor="white">
<p>Your login failed! Click <a href="login.htm">here</a> to try again.</p>
<%
else
'Successful login
Session("ENABLED") = true
Session("USERNAME") = rs("userName")
Session("REALNAME") = rs("realName")
Session("ACCESSLEVEL") = rs("accessLevel")
if rs("webadmin") then
Session("webadmin") = rs("webadmin")
end if

'Close database connection
conn.Close
set conn = Nothing
'Response.Redirect "menu.asp"
auth = 1
end if
else
Response.Write("<BODY background=../myadmin/backgd.gif>Connection Failed. <BR> " & Err.Description )
end if

'conn.Close
set conn = Nothing
%>
</BODY>
</HTML>
<%if auth = 1 then%>
<SCRIPT LANGUAGE="JavaScript">
<!--
parent.TopLogo.location.href="TopWithMenu.asp";
window.location.href="menu.asp";
//-->
</SCRIPT>
<%end if%>

8:00 pm on Jan 30, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member txbakers is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Sept 1, 2001
posts:4392
votes: 0


Hi and Welcome to the Webmaster World!

Rs.ActiveConnection = "FILEDSN=&session("dataLocation")&"christiansf_TheData.dsn"

You have an extra quote mark before christiansf_TheData

There are three quotes in that string, beside the two for the session variable.

9:02 pm on Jan 30, 2005 (gmt 0)

New User

10+ Year Member

joined:Jan 30, 2005
posts:3
votes: 0


Tried that to no avail. This is the way it was on the other server that worked, before they made me change the DSN with the underscore character in it and the prefix:

strQuery = "SELECT * FROM UFC_Users_Table " &_
"WHERE userName = '" & UserName & "' AND " &_
"password = '" & Password & "'"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "FILEDSN="&session("dataLocation")&"TheData.dsn"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.ActiveConnection = "FILEDSN="&session("dataLocation")&"TheData.dsn"
Rs.Open strQuery, Conn, 3, 3

12:20 am on Jan 31, 2005 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 12, 2004
posts:393
votes: 0


You need to use the MapPath method to map a virtual address to a physical address.

Conn.Open "FILEDSN=" & Server.MapPath("christiansf_TheData.dsn")

4:57 am on Jan 31, 2005 (gmt 0)

New User

10+ Year Member

joined:Jan 30, 2005
posts:3
votes: 0


Thanks much, I am on the trail now. I have other errors I am working on after this one.
7:12 am on Jan 31, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 31, 2003
posts:196
votes: 0


Just compare the two, and spot the missing "

Rs.ActiveConnection = "FILEDSN=&session("dataLocation")&"christiansf_TheData.dsn"
Rs.ActiveConnection = "FILEDSN="&session("dataLocation")&"TheData.dsn"