I am currently working with a vb2010 front end with access as the database. everything works for accessing the information adding information. But when I try to edit/update the contents of a row I find that the update is being applied to the first row of the table rather than the target row. i have tried using the ID as a way to specify the row i want updated but that doesn't appear to work.

UPDATE       ExamContent
SET                Question = ?, ExamsText = ?, [Answer 1] = ?, [Answer 2] = ?, [Answer 3] = ?, [Answer 4] = ?, CORRECT = ?, LastEditUser = ?, LastEditDate = ?
WHERE        ID = ?

The corresponding code is then written like this,

Me.ExamContentTableAdapter.UpdateQuery(Question:=QuestionNumberBox.Text, ExamsText:=QuestionBox.Text, Answer_1:=Answer1.Text, Answer_2:=Answer2.Text, Answer_3:=Answer3.Text, Answer_4:=Answer4.Text, CORRECT:=Correct.Text, LastEditUser:=AAULoginForm.usertxt.Text, LastEditDate:=Date.Now.ToShortDateString, Original_ID:=IDTextBox.Text)

as i say the update is getting thru but is applied to the wrong row. what am i missing?

Recommended Answers

All 4 Replies

Is the ID unique per record or is it some sort of identifier to group your records by or link them to users, etc?
I'm guessing it's not, so you need to change the criteria so you end up with the correct and unique record. Try a select and keep adding criteria until you end up with the correct result.
Sorry but I can't help any further without the table specs and possibly some sample data

The ID is unique and is the primary key, its the one that access generates for each new record so it is not getting mixed up there....

so the question is resolved. There were a couple of things that were stepping on each others feet, first I was updating a table adapter that had already been set with very specific parameters(eg it was a fillby command that returned 10 rows from a possible 500) when i was trying to be specific and specify the row i was updating i was referencing the row in relation to the possible 500 not the fillby table which returned 10 results.
glad thats over. its good to have friends with a bit more knowledge :)

Nothing as fantastic as troubleshooting a problem yourself. ;)

Be a part of the DaniWeb community

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