We help IT Professionals succeed at work.
Get Started

Generating a Unique Random Number VB.Net against a View

nomar2
nomar2 asked
on
369 Views
Last Modified: 2012-05-09
I have a piece  of VB.Net code that generates a random number and this value gets inserted into a row in a table. I use.

.Dim RandomNumber As Long
RandomNumber = RandomClass.Next(1000, 99999)

.no problem ..

Now I find out they don't want use the same number twice.. so I was thinking of creating a view of the table that shows all the numbers so far that was used.. and compare the newly generated number against the view ..if it exists..generate another number..if it doesn't exist in the table..then insert the value into the row in the table..

My view is called vRandom and hold 2 values the Rowid and iRandom

Just wondering what would be the best approach codewide
Any help or insight would be much appreciated..
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE