user1579831
user1579831

Reputation:

How to check the database that record does exist?

I developed the program on vb.net 2008 using multiple forms.

One of the forms must check the database, to see if the student ID number exists in the database.

If the is no such ID number in the database, the program should notify the user with the massage box indicating that "there is no such ID number", otherwise, if the ID number does exist on the database the ID should be shown on the dataGridView that I already created.

I’m using the MS Access for database

Upvotes: 0

Views: 898

Answers (2)

Scotch
Scotch

Reputation: 3226

I think that the DLookup() function would be a good fit for you. DLookup can look up a specific value from a recordset. It will return null if there is no match. You can find more information on DLookup here : DLookup Function

Upvotes: 0

Losbear
Losbear

Reputation: 3314

Without seeing any code it's hard to give any examples, but you could get the count of of how many students have that id (therefore, if it exists):

select count(*) from [students table] where id = [The id to compare]

if count > 0 then it exists. if it's not (if it equals 0), then it doesn't exist and you could display your message.

Upvotes: 1

Related Questions