|
 |
asp_databases thread: Cant get this script to work.. Check to see if username already exists
Message #1 by "Brad" <insuran@m...> on Fri, 19 May 2000 18:38:21
|
|
<% dim strusername, strpassword, stremail
strusername = request.form("username")
strpassword = request.form("password")
stremail = request.form("email")
%>
<%
Dim connstring, my_conn, myrecordset, counter
connstring = "DRIVER={SQL
Server};SERVER=SQLDATA;LANGUAGE=us_english;DATABASE=***;UID=***;PWD=***"
set my_conn=server.createObject("adodb.connection")
set my_recordset= Server.CreateObject("ADODB.recordset")
my_Conn.Open ConnString
counter = "Select username from handicap where username = '" & strusername
& "';"
my_conn.Execute counter
if counter.recordcount > 0 then
response.write "username exist please enter another"
else
response.write "username doesnt exist"
end if%>
Message #2 by "Ken Schaefer" <ken.s@a...> on Sat, 20 May 2000 14:29:06 +1000
|
|
> counter = "Select username from handicap where username = '" & strusername
> & "';"
> my_conn.Execute counter
> if counter.recordcount > 0 then
> response.write "username exist please enter another"
> else
> response.write "username doesnt exist"
a) Next time, please include the error message you are getting. Saying "This
doesn't work" doesn't help us much in helping you
b) You are creating "counter" as a variable containing a string. Then you
are doing this:
counter.recordcount
However a variable of subtype variant has no property .recordcount. Instead
you need to create a recordset which contains the results of executing
"counter" against my_conn.
Do this instead:
<%
Dim objRS
strSQL = "SELECT Username FROM handicap WHERE username = "' & strUsername &
"'"
set ObjRS = my_conn.execute(strSQL)
if objRS.EOF and objRS.BOF then
Response.Write("Username doesn't exist.")
else
Response.Write("Username exists, please enter another.")
end if
objRS.close
set objRS = nothing
%>
|
|
 |