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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If record is not there.. what to do?

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
0
0
PH
I am calling a recored using the users username, how do write out "User not found" if the user doesn't exsist in the db?

- Thanks
 
If not is database

if not rstChkAgain.EOF then
Response.write "results "&rstChkAgain("username")
else
Response.write "Nothing found"
End if Regards gsc1ugs
"Cant see wood for tree's...!"
 
Is the check

strSQL = "SELECT username, password FROM users WHERE username = '" & Request.Form("yourusername") & "' AND passwrod = '" &Request.Form("yourpasswrod")&"'"
Set rstChkAgain = objConn.Execute(strSQL)

if not rstChkAgain.EOF then
Response.write "results "&rstChkAgain("username")
else
Response.write "Nothing found"
End if
Regards gsc1ugs
"Cant see wood for tree's...!"
 
Is the check

strSQL = "SELECT username, password FROM users WHERE username = '" & Request.Form("yourusername") & "' AND passwrod = '" &Request.Form("yourpasswrod")&"'"
Set rstChkAgain = objConn.Execute(strSQL)

if not rstChkAgain.EOF then
Response.write "results "&rstChkAgain("username")&" Logged in"
else
Response.write "Nothing found"
End if
Regards gsc1ugs
"Cant see wood for tree's...!"
 
I get an error using the first code:

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

set my_conn= Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.RecordSet")

my_conn.Open ConnString

StrSQL = "SELECT * FROM users WHERE username=" & "'" & Request.QueryString("username") & "'"

rs = my_conn.Execute (StrSQL)

'# ------------------------

Microsoft VBScript runtime error '800a01b6' 

Object doesn't support this property or method: 'EOF' 

/profile.asp, line 105 

'# ------------------------

<% if not rs.EOF then
Response.write &quot;Found&quot;  '( just testing )
else
    Response.write &quot;Nothing found&quot;
End if 
%>
 
This is wrong

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

Should be

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

Is the username in the reply back...ie
name.asp?username=gary....? if not then the above wont work..you need to get the username from your form or out in in the link... Request.form(&quot;username&quot;) ...


just to summarise..

users = table in db
Request.form(&quot;username&quot;) = from tour form
else
Request.QueryString(&quot;username&quot;) from your reply back in link
ie name.asp?username=gary

then really syntax should be

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

then use

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

Hope it helps


Regards gsc1ugs
&quot;Cant see wood for tree's...!&quot;
 
- Thanks for all your help..Im new to the forums how do you rate a person so I can rate you..?

This won't work because you are commenting out the querystring line..
Code:
StrSQL = &quot;SELECT * FROM users WHERE username=&quot; & '&quot; & Request.QueryString(&quot;username&quot;) & &quot;'

The strSQL I am using works fine, I can get a user and display there record with profile.asp?username=username, its just if you goto a user that is not there it shows this:

---------------------------------------
ADODB.Field error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

profile.asp, line 31
---------------------------------------

I am calling a user exactly how this site is calling a user:
This is a sample of a user that doesnt exsist...


It actully removes the middle tables and everything... and then says &quot;This user does not exist&quot;
 
Sorry your correct

SQL = &quot;SELECT * FROM users WHERE username=&quot; & &quot;'&quot; & Request.QueryString(&quot;username&quot;) & &quot;'&quot;


If you feel the thread as been useful then you click the

Click here to mark this post as a helpful or expert post!

Tara :-0 Regards gsc1ugs
&quot;Cant see wood for tree's...!&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top