I’m having some issues generating a unique ID, and also checking to make sure that the generated ID is not already in the database. I wrote two simple functions, but every time they run, I get an out of memory error.
Is there a better way of doing this?
Here is my code:
uniqueID = getID()
function getID()
Dim id : id = getUniqueID 'simple random number generator
if checkForID(id) = 0 then
return id
else
id = getID()
end if
end function
function checkForID(id)
SQL="SELECT * FROM userOrderDxTest WHERE orderID =" & id
set rs=Server.CreateObject("ADODB.recordset")
rs.Open SQL,DB,adOpenStatic
if not rs.EOF then
checkForID = 1 'ID already exists
rs.close
set rs = nothing
else
checkForID = 1 'ID doesn't exist
rs.CLOSE
end if
end function
you always set checkForID to 1. It should be: