Hi there, Im new to vb and i am using visual basic express 2010.
i have put together a database and can do quite a lot with the app i have created.

i am not very familiar with detailed programming so i have created my update query thru the dataset tools in visual basic express. i get a data mismatch error from the code i am using, but when i look for answers online they refer to purely coded update queries as opposed to what i can see in vb express.

this is the code i have in place

Private Sub UpdateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateButton.Click

        Me.AssociatesTableAdapter.UpdateQuery(FirstName:=FirstNameBox.Text, LastName:=LastNameBox.Text, Training:=TrainingBox.Text, _
                                              Department:=DepartmentBox.Text, Password:=PasswordBox.Text, Original_FirstName:=FirstNameBox.Text, _
                                              Original_FirstName1:=FirstNameBox.Text, Original_LastName:=LastNameBox.Text, Original_LastName1:=LastNameBox.Text, _
                                              Original_Training:=TrainingBox.Text, Original_Training1:=TrainingBox.Text, Original_Department:=DepartmentBox.Text, _
                                              Original_Department1:=DepartmentBox.Text, Original_Password:=PasswordBox.Text, Original_Password1:=PasswordBox.Text)
  

    End Sub

The query code looks like this

UPDATE    Associates
SET              FirstName = ?, LastName = ?, Training = ?, Department = ?, [Password] = ?
WHERE     (? = 1 AND FirstName IS NULL OR
                      FirstName = ?) AND (? = 1 AND LastName IS NULL OR
                      LastName = ?) AND (? = 1 AND Training IS NULL OR
                      Training = ?) AND (? = 1 AND Department IS NULL OR
                      Department = ?) AND (? = 1 AND [Password] IS NULL OR
                      [Password] = ?)

any suggestions? i have checked my access database columns for type and they are correct (all of the fields are text)

since i am not really familiar with sql etc i am assuming something is wrong with my syntax, but vb didn't indicate any problems with the way it was written.

thank you for any assistance, it is much appreciated.

FirstName:=FirstNameBox.Text << ok
Original_FirstName1:=FirstNameBox.Text << that won't work out

You hand over the "updated" values as original values. Those of course does not exist in the dataset.

So what syntax must be used for the

Original_FirstName1:=FirstNameBox.Text

if i'm not supposed to use the firstnamebox.text ... i won't always know the original information and i can enter every possible value imaginable...

Its not just about the firstname. look again at your updatequery, its using ALL original values to find the record to update.
So either you store the original values before they change or, if your textboxes are databound you use the Me.AssociatesTableAdapter.Update method.

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.