I have a function that creates a random number used for a transaction number. I would like to run the function and then check the database to see if the transaction number already exists. If it does, I want to rerun the random number generator until a unique transaction number is generated. Would anyone be able to help? Im not quite sure how to set this up. Thanks in advance!Hi there,
I'd do something like this:
Dim tid as Integer = YourRandomNumberMethod()While TIDExistsInDB(tid)
tid = YourRandomNumberMethod()
End While
Note, this is rather in efficient as it has to make potentially numerous calls to the DB. You'd be much better suited just puting an identity column on teh table you're tracking transactions in.
0 comments:
Post a Comment