Forum Moderators: open
"Microsoft VBScript runtime error '800a000d'
Type mismatch: 'stconn'
/members.asp, line 10
Which i am not understanding why. Here is the code
<!-- #include file="includes/connection.inc" -->
**This is the Connection File**
<%
Set cn=Server.CreateObject("ADODB.Connection")
cn.Mode=3
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("../data/backend.mdb") & ";"
cn.Open strconn
function EncodeThisText(text)
if(instr(text, "'")) then
text = replace(text, "'", "'")
elseif(instr(text, """")) then
text = replace(text, """", """)
end if
EncodeThisText = text
end function
%>**End Of Connection file**
<%
if session("user_name") = false or session("password") = false then
response.redirect "login.asp"
end if
name = session("name")
user_name = session("user_name")
password = session("password")
**(line 10)**stconn "Select * From users Where user_name = '" & user_name & "'"
'strSQL = "SELECT field1, field2 FROM table1"
stconn.Open stconnSQL, stconnConnect, adOpenForwardOnly, adLockReadOnly, adCmdText
if stconn.eof then
response.redirect "login.asp"
else
if stconn("password") <> password then
response.redirect "login.asp"
end if
end if
%>
I have tried different things that were suggested, while i was looking everywhere. Any ideas?
Microsoft VBScript runtime error '800a01a8'
Object required: 'stconn'
/members.asp, line 12
it is the same code as posted in the first message, but here is line 12
stconn.Open stconnSQL, stconnConnect, adOpenForwardOnly, adLockReadOnly, adCmdText
Microsoft VBScript runtime error '800a01a8'
Object required: 'cn'
/members.asp, line 12
same line
cn.Open cnSQL, cnConnect, adOpenForwardOnly, adLockReadOnly, adCmdText
when i take that line out it gives me this error
Microsoft VBScript runtime error '800a01a8'
Object required: 'cn'
/members.asp, line 13
and line 13 is
if cn.eof then
which i know i need to have the connection openned before it can run the eof check.
I have also tried taking everthing off of line 12 so that it is only
cn.Open
and that is still giving the same error
Microsoft VBScript runtime error '800a01a8'
Object required: 'cn'
/members.asp, line 12
Secondly, You need a recordset for the results. Also, simplify the steps instead of trying to do everything on one line/statement.
Dim cn
'put this above the INCLUDE statement so the include file uses your local variable.
'Open the Connection
Set cn=Server.CreateObject("ADODB.Connection")
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("../data/backend.mdb") & ";"
cn.Open strconn
'Now the Recordset
Set rs = Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection = cn
rs.CursorType = adOpenForwardOnly
strSQL = Select * From users Where user_name = '" & user_name & "'"
rs.open strSQL
'Now cycle through the results
Do While Not rs.EOF
Response.write rs.Fields("fieldnamehere") & "<BR>"
Loop
'Now clean up
cn.close
rs.close
cn = nothing
rs = nothing
Here is the code and how it was changed, I am not including the include file this time. I didn't make any changes to it.
<!-- #include file="includes/connection.inc" -->
<%
Dim cn
<***this was above the inclued file but it was showing up on the page, so i moved it down.**>
if session("user_name") = false or session("password") = false then
response.redirect "login.asp"
end if
name = session("name")
user_name = session("user_name")
password = session("password")
Set cn=Server.CreateObject("ADODB.Connection")
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("../data/backend.mdb") & ";"
cn.Open strconn
Set rs = Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection = cn
rs.CursorType = adOpenForwardOnly
strSQL = "Select * From users Where user_name = '" & user_name & "'"
rs.open strSQL
if rs.eof then
response.redirect "login.asp"
else
if rs("password") <> password then
response.redirect "login.asp"
end if
end if
%>
This is more of the ASP that is on the page.
<%
if session("discount") = "true" then
response.write ("<script type=""text/javascript"">window.open(""special.asp"","""",""height=322, width=374, top=50, left=50"")</script>")
end if
%>
this at the very bottom of the page, reason it was not doing what it was suppose to, it would give me and error:
ADODB.Recordset error '800a0e78'
Operation is not allowed when the object is closed.
So then i moved it to the bottom of the page and it work except that i am getting and error on the bottom of the page. I have it right before the body closes. Code first:
<%
cn.close
rs.close
cn = nothing
rs = nothing
%>
Now the error i get when i run it the way i have it. (which is the error on the webpage itself.)
ADODB.Recordset error '800a0e78'
Operation is not allowed when the object is closed.
/members.asp, line 72
this is line 72
**rs.close**
I just relized that when i run it either way, it is giving me a problem at the "rs.close" line, no matter where i have it setting.