Last post Jan 04, 2011 09:07 AM by LesMc
Jan 03, 2011 01:08 PM|LesMc|LINK
I have this Insert statement working fine:
tQuestionsInsertTableAdapter newQ = new tQuestionsInsertTableAdapter();
newQ.Insert(Question, Answer, TypeID, PointID, AuthorID, RefIdentity, QuizYear, SetType, DivisionID);
It inserts a new record into a single table. The PK is a field named QID.
Does anybody know what the equivalent Update code would be? I'm not sure of the syntax for the Update values (old and new) and Where clause.
I'm assuming something beginning with: existingQ.Update(...
Any help is appreciated.
Jan 03, 2011 10:12 PM|khab2010|LINK
Either get the datatable or datarow and edit the fields. Finally pass the either of them to the Update method of the dataadapter. All of this is explained very well in the link below:
Jan 04, 2011 09:07 AM|LesMc|LINK
Actually, I figured it out, and the solution is very elegant code. It is simply this:
newQ.Update(Question, Answer, TypeID, PointID, AuthorID, RefIdentity, QuizYear, SetType, DivisionID, QuestionID);
With the PIK already defined in the TableAdapter, by adding it as the last parameter in the string above with the Update command, the TableAdapter knew what to do with it.
Viola, very clean.