I have javascript with vbscript in my adduser.asp page.
the code below is supposed to show you the "user name exists" alert only when the recordcount is not 0, meaning the select statement found that user in the database.
But what it is doing is first inserting the new user (recordcount is 0) but then showing the alert saying "user name exists"
I think it first sees recordcount as 0 but then after the inset it updates the recordcount to 1 and then shows the alert.
If this is happening I need to find a way to get around this. Does anyone have any good suggestions about this? Any code samples would be great, I'm really stumped on this.
<CODE>
set chkrs = server.CreateObject("adodb.recordset") chkrs.cursorlocation = 3
chkrs.open "Select * from Tbl where user='"&trim(username)&"'", strconn
if chkrs.recordcount = 0 Then set regrs = server.CreateObject("adodb.recordset") regrs.open "insert into Tbl (User) values ('"&trim(usr)&"')",strconn %> <Script language="javascript"> alert("New User Created Successfully ! ") window.location='somepage.asp' </script> <% else %> <Script language="javascript"> alert("User Name Exists") </script> <%
end if
</CODE>