Jul 31, 2006 #1 J jespermohl New member Joined Jan 21, 2005 Messages 3 Location Copenhagen How do I modify the data in my datatable, when it allready contains a row with the primary key? I dont know how to find the index? in C#.
How do I modify the data in my datatable, when it allready contains a row with the primary key? I dont know how to find the index? in C#.
Jul 31, 2006 #2 M MickD Member Joined Jul 30, 2006 Messages 6 Location Gerringong, NSW Australia Do you want to change one record in particular of the currently available one? to iterate the records - foreach(DataRow dr in dt.Rows) { //change the data in the current record (DataRow) } To get a particular record you would need a query to get the record such as - Select SomeRecordColumnData from mytable where SomeOtherRecordsColumnData = "SomeParticularData"; Then you should have a dataset with one datatable with one DataRow or record. Change it by something like- dr["SomeRecordColumnData"] = "Some new data"; Then you have to use the dataAdaptorss Update method to merge your data set with the original database. hth, Mick.
Do you want to change one record in particular of the currently available one? to iterate the records - foreach(DataRow dr in dt.Rows) { //change the data in the current record (DataRow) } To get a particular record you would need a query to get the record such as - Select SomeRecordColumnData from mytable where SomeOtherRecordsColumnData = "SomeParticularData"; Then you should have a dataset with one datatable with one DataRow or record. Change it by something like- dr["SomeRecordColumnData"] = "Some new data"; Then you have to use the dataAdaptorss Update method to merge your data set with the original database. hth, Mick.