Groups | Blog | Home
all groups > inetserver asp db > june 2004 >

inetserver asp db : Check username to see if already used


Jeff
6/18/2004 10:32:05 AM
I know this is an easy script. I used to know it actually, but forget it.

Before updating my DB with the new entry... i want it to check the username
field, to see if the username that someone is trying to register with
already exists. I used to know this if then statement. But just getting back
to writting asp after a few years.. i dont remember.
Can someone help me?
Jeff

jeff.nospam NO[at]SPAM zina.com
6/18/2004 7:58:46 PM
On Fri, 18 Jun 2004 10:32:05 -0400, "Jeff"
[quoted text, click to view]

You don't mention the databse type, but normally you'd use an IF
EXISTS clause in your query. Check your database docs for examples if
this command exists.

Bullschmidt
6/21/2004 10:39:44 PM
Perhaps this will give you some ideas even though it uses a custom
function called jpsvbDLookup():

' Don't allow edit to a changed CustID that already exists.
If (strValid = "") And (CustID <> CustIDOrig) And (CustIDOrig <> "")
Then
' Count.
' Set sql.
strSQL = "SELECT Count(*) AS RecCount "
strSQL = strSQL & "FROM tblCust "
strSQL = strSQL & "WHERE (CustID=" & Chr(39) & jpsvbFixSQL(CustID) &
Chr(39) & ")"
If jpsvbDLookup(objConn, objRS, strSQL, 0, 0) > 0 Then
strValid = "Cannot save this edited record because the changed
Customer Num already exists."
End If
End If

Best regards,
J. Paul Schmidt, Freelance ASP Web Designer
http://www.Bullschmidt.com
ASP Designer Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


*** Sent via Devdex http://www.devdex.com ***
AddThis Social Bookmark Button