0

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

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by debasisdas
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.