Hi this is the code i have

NewCustomerTable.Clear()
NewCustomerconnection.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=G:\Shop.mdb"
NewCustomerconnection.Open()
NewCustomerAdapter = New OleDb.OleDbDataAdapter("INSERT INTO Customers VALUES ('" & txtNewID.Text & "','" & txtNewFirstName.Text & "','" & txtNewLastName.Text & "','" & txtNewAddress1.Text & "','" & txtNewAddress2.Text & "','" & txtNewPostcode.Text & "','" & txtNewPhoneNumber.Text & "')", NewCustomerconnection)
CommandBuilder = New OleDb.OleDbCommandBuilder(NewCustomerAdapter)
            NewCustomerAdapter.Fill(NewCustomerTable)
            NewCustomerconnection.Close()

i have a button called btnUpdate
and when i click on update i want the program to check to see if the ID number already exists within the database but i cant seem to figure out how to do that. plz help

you need to check for existance of the ID before trying to insert a new record. If it exists prompt the user to enter a new ID or can increment the max(id) by 1 and continue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.