Click to See Complete Forum and Search --> : Error:ADODB.Recordset (0x800A0CC1)


Tortured Lady
10-22-2004, 07:12 AM
hiii,, i feel that my previous question is a little bit unclear
so this is another question ... i am getting this error ..
-------------------
Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.

---------------

this is my code ...


<%

Posted = Request.Form("posted")
If Posted = "" Then
%>
<form name="form1" method="post" action="">
<table width="27%" align="center">
<tr bgcolor="#CCCC99">
<td colspan="2" class="class"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">::
Sign In ::</font></strong><br>
---------- </td>
</tr>
<tr bgcolor="#CCCC99">
<td width="44%" class="class" ><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Username</font></td>
<td width="56%" class="class" ><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<input name="uname" type="text" id="uname" size="15">
</font></td>
</tr>
<tr bgcolor="#CCCC99">
<td class="class" ><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Password</font></td>
<td class="class" ><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<input name="pass" type="password" id="pass" size="15">
</font></td>
</tr>
<tr bgcolor="#CCCC99">
<td class="class" ><font size="1" face="Verdana, Arial, Helvetica, sans-serif">name</font></td>
<td class="class" ><input name="myname" type="text" id="myname" size="15"></td>
</tr>
<tr bgcolor="#CCCC99">
<td class="class" ><font size="2" face="Bookman Old Style">
<input class="font" type="submit" name="Submit" value="Submit">
</font></td>
<td class="class" ><font size="1" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;</font>
<input name="posted" type="hidden" id= "posted" value="yes"></td>
</tr>
</table>
</form>
<%
else
'Function FixQuotes(theString)
'fixQuotes = Replace (theString, "'", "''" )
'end Function

username = request.form("uname")
password = request.form("pass")
myname = request.form("myname")

Errmsg = ""

Response.Write "<UL>"
if username = "" then
Errmsg = Errmsg & "<br><br><LI>Username cannot be empty"
end if

if len(username) < 4 then
Errmsg = Errmsg & "<br><br><LI> Username can't be less than 4"
end if

if username = password then
Errmsg = Errmsg & " <br><br><LI> Name can't be the same as the password"
end if

if len(password) < 4 then
Errmsg = Errmsg & " <br><br><LI> Password can't be less than 5 "
end if
Response.Write"</UL>"

if Errmsg <> "" then
Response.Write "<font size='4' Color='Red'><U><B> Sorry,You Had The Following Errors:<P></U></B></Font>" & ErrMsg & "</I></center>"
else

set MyConn = server.createObject("ADODB.Connection")
MyConn.open("dbProject")

SQL = "select username,password,myname from users where username = '"& username & "'"
set MyRS = MyConn.execute(SQL)
if MyRS.BOF and MyRS.EOF then
SQL = "Insert into users (username,password,myname)"
SQL = SQL & "values('"& username &"','"& password &"','"& myname &"')"
set MyRS = MyConn.execute(SQL)
Response.Write "<font size='5' Color='blue'><Center>Congratualtions, <U><b>" & username & "</b></U><br><br>Your registration is completed succressfully</font>"
Session("username") = MyRS.fields("username")
'session("password") = MyRS.fields("password")
Response.Redirect("Feedback.asp")
'set MyRS = Nothing
'MyConn.Close
Else
Response.Write "<center><font size= 4 color= 'red'> The username You Have Chosen Already Exists.</font>"
end if
'MyConn.close
end if
end if

%>



Please help me .. waiting for ur respond ..

buntine
10-22-2004, 08:09 AM
This error is received when you try to reference the name of a table field or alias that does not exist.

In this case, you are getting the error because you are trying to return records from an INSERT INTO statement, which is DML so it cannot return records.

What you have to do is reference the variables instead.

set MyConn = Server.CreateObject("ADODB.Connection")
MyConn.Open("dbProject")

SQL = "select username,password,myname from users where username = '"& username & "'"
Set MyRS = MyConn.Execute(SQL)

If MyRS.BOF And MyRS.EOF Then
SQL = "Insert into users (username,password,myname)" & _
" values('"& username &"','"& password &"','"& myname &"')"
MyConn.execute(SQL)
Response.Write "<font size='5' Color='blue'><Center>Congratualtions, <U><b>" & username & "</b></U><br><br>Your registration is completed succressfully</font>"
Session("username") = username
'Session("password") = password
Response.Redirect("Feedback.asp")
'set MyRS = Nothing
'MyConn.Close
Else
Response.Write "<center><font size= 4 color= 'red'> The username You Have Chosen Already Exists.</font>"
End If

Session("username") = MyRS.Fields("username") is the line which was causing the error i'd say.

Regards.