Hi
I've got this bit of code which basically checks that the username a customer has chosen hasn't been already used. If it has then it says either try again or it sugessts one by concatenating their effort with the @@identity. I'm missing a loop or something though because when it gets to the line
llIDnew = left(str, 8) & "" & llID
i need to check that the value of llIDnew doesn't exist also or either try another one, if you see what i mean ! (i.e. insert another record into tblUserNames get the @@identity from that record and try that again until it gets an unused one)
any ideas appreciated
richey
SQLNameCheck = "SELECT UserName from tbluserNames where UserName = '" & cleansql(str) & "'"
set objRSName = objCon.Execute(SQLNameCheck)
if not objRSName.eof then
ErrorMsg1 = ErrorMsg1 & "The UserName has been already used - "
ErrorMsg1 = ErrorMsg1 & "Please try to select a unique username; you may want to try adding numbers to your username,
(e.g.johnsmith1234). "
SQLSuggestName = "INSERT INTO tblUserNames(UserName)"
SQLSuggestName = SQLSuggestName & " VALUES ("
SQLSuggestName = SQLSuggestName & "'" & cleansql(str) & "'"
SQLSuggestName = SQLSuggestName & ")"
objCon.execute(SQLSuggestName)
lsSQL = "SELECT @@IDENTITY AS NewID"
Set loRs = objCon.Execute(lsSQL)
llID = loRs.Fields("NewID").value
llIDnew = left(str, 8) & "" & llID
ErrorMsg1 = ErrorMsg1 & "Alternatively use " & left(str,8) & "" & llID & "<br></br>"
else
end if
I've got this bit of code which basically checks that the username a customer has chosen hasn't been already used. If it has then it says either try again or it sugessts one by concatenating their effort with the @@identity. I'm missing a loop or something though because when it gets to the line
llIDnew = left(str, 8) & "" & llID
i need to check that the value of llIDnew doesn't exist also or either try another one, if you see what i mean ! (i.e. insert another record into tblUserNames get the @@identity from that record and try that again until it gets an unused one)
any ideas appreciated
richey
SQLNameCheck = "SELECT UserName from tbluserNames where UserName = '" & cleansql(str) & "'"
set objRSName = objCon.Execute(SQLNameCheck)
if not objRSName.eof then
ErrorMsg1 = ErrorMsg1 & "The UserName has been already used - "
ErrorMsg1 = ErrorMsg1 & "Please try to select a unique username; you may want to try adding numbers to your username,
(e.g.johnsmith1234). "
SQLSuggestName = "INSERT INTO tblUserNames(UserName)"
SQLSuggestName = SQLSuggestName & " VALUES ("
SQLSuggestName = SQLSuggestName & "'" & cleansql(str) & "'"
SQLSuggestName = SQLSuggestName & ")"
objCon.execute(SQLSuggestName)
lsSQL = "SELECT @@IDENTITY AS NewID"
Set loRs = objCon.Execute(lsSQL)
llID = loRs.Fields("NewID").value
llIDnew = left(str, 8) & "" & llID
ErrorMsg1 = ErrorMsg1 & "Alternatively use " & left(str,8) & "" & llID & "<br></br>"
else
end if