random number and database check

ikmfali

New Member
I'm having some issues generating a uniqueID, and also checking to make sure that the generatedID is not already in the database. I wrote 2 simple functions, but everytime they run, I get an out of memory error.Is there a better way of doing this?THanks!Here is my code:\[code\]uniqueID = getID()function getID()Dim id : id = getUniqueID 'simple random number generator if checkForID(id) = 0 then return id else id = getID() end ifend functionfunction 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 ifend function\[/code\]
 
Back
Top