I have an add/edit program I've written and I'm trying to find an example of how to test/check an Account Number that a person enters in a textbox to the database(SQL) to make sure it is unique. I've been searching and haven't had any luck. Any Advice? Thanks.
So you're gonna have to check more than 1 account number in the database, so you'll need to use loops, and prob a substring and compare each character to see if they have the corresponding char from the textbox, and if none of them do, it's unique.
So, say the account number in the textbox is 300, and you have 3 account numbers in the database, 100, 320, 300.
The first thing you would do is compare the first character of 300 in the textbox, which is 3, to the first character of 100 in the database, which is 1. They're not equal, so you can skip to the first character 2nd number, which is 3. They are equal, so now you need to compare the second character of the textbox 300, which is 0, to the second character of the 320, which is 2. They're not equal, so you skip to the comparing the first numbers of both 300s, then the second and third numbers. Since all 3 characters are the same, you would return not unique or whatever. Hope that helps you a bit.