I have a database with a few records. I have a datagridview which is bound to a dataset. I can click on a record in the datagrid view and display information from the fields into corresponding textboxes. I am using SQL CE software.
What I would like to do is say I edit some text in a textbox, I would like to update the corresponding field that the textbox relates to in the database table permanantly.
E.g Say I have a textbox called Forename and I edit the forename of a selected patient record. It should update that particular patients forename.
I used these two methods:
tableAdapter1.Update(MyPatientsDataSet.Patients); tableAdapter1.Fill(MyPatientsDataSet.Patients);
But the problem that occurs is if i invoke the Update method on the adapter the record is only updated temporarily which is not what I want. So then i used the fill method but that doesnt update the row with the updated values permanantly.
This is the code I have attempted:
try {
this.PatientForename = Forename.Text;
this.PatientSurname = Surname.Text
//Datagrid view mouse click event sets the position 'pos' globally.
PatientsGridView.Rows[pos].Cells[1].Value = this.PatientForename;
PatientsGridView.Rows[pos].Cells[2].Value = this.PatientSurname;
//it is here i call the update and fill methods.
}
catch(Exception ex)
{
Console.Writeline(ex.StackTrace.ToString());
}
I wondering if someone could assist me please? I would really appreciate your help.
Thanks in advance.
*01/17/10 - Just tried again today to see if i could get it to work. If i take the "Fill" statment out the changes are only made temporarily and not permanantly. I would appreciate if somebody could advise on this.
This post has been edited by MarmiteX1: 17 January 2010 - 07:03 AM

New Topic/Question
Reply




MultiQuote








|