Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EOF & BOF are not working..

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
PH
No matter what I try I can't get it to not error if a user is not found. I have tried everything accept the right way I guess!

I get this error trying to do it this way:


If Not rs.EOF Then
Response.write username
else
Response.write "Not found"
end if


Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'EOF'
profile.asp, line 65

I have tried this way as well:


If EOF or BOF then
response.write "user not found"
else
response.write username
end if


Any suggestions??

-Jason
 
Have you tried wrapping "" around username? Is username a field item?
Occasionally I have found that enclosing the response statement within the <% %> helps.

Give it all a go!

M
 
Its not the username ...it errors on the EOF line.
 
The reason I mentioned the above was that I was getting a similar error when trying a fiddly response.redirect.

&quot;Object doesn't support this property or method: 'EOF'&quot;

Sorry to be blunt, but rs is the name of your recordset?

(Don't ask - you'd be surprised!)

get back with a bit more of your code..

M
 
yea its rs ;) lol thats the first thing i checked.. good thought though somedays I'd have probably looked over it...but this little &quot;problem&quot; has been with me for a couple of days now..

Code:
ConnString = &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & Server.MapPath(&quot;db.mdb&quot;)

set my_conn= Server.CreateObject(&quot;ADODB.Connection&quot;)
set rs = Server.CreateObject(&quot;ADODB.RecordSet&quot;)

my_conn.Open ConnString

strUsername = CStr(Request.Querystring(&quot;username&quot;))

StrSQL = &quot;SELECT * FROM users WHERE username=&quot; & &quot;'&quot; & strUsername & &quot;'&quot;


'StrSQL = &quot;SELECT * FROM users WHERE username=&quot; & &quot;'&quot; & Request.QueryString(&quot;username&quot;) & &quot;'&quot;  [works]

rs = my_conn.Execute (StrSQL)


If rs.bof and rs.eof then 

Response.write &quot;User not found&quot;
Response.End
else
'Build page..
%>
 
I think the problem is not with EOF and BOF the problem is with the RS object itself. For some reasons it might not have set. So first check if RS is really is not NOTHING. So before

rs = my_conn.Execute (StrSQL)

statement use:

if rs is nothing then
Response.rtie(&quot;error in getting records.&quot;)
Else
if not(rs.EOF and rs.BOF) then
response.write(&quot;records Present&quot;)
Else
response.write(&quot;No records.&quot;)
End IF
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top