Hello, everybody .I have a question about database.Can you help me ,please.I have a datagridview which contain three cell are Name,ID,Time
Name | ID | Time
Toan | 123 | 7:00:01
Tien | 122 | 7:00:02
Tuan |124 |7:00:03
Toan |123 |7:00:05
Tuan |124 |7:00:07
I want to use C# and Sql to remove the first row Toan | 123 | 7:00:01 and Tuan |124 |7:00:07 because two rows have same data and if Name is same ,I will delete a row which has old time (Toan | 123 | 7:00:01
and Toan | 123 | 7:00:05 the program will delete Toan | 123 | 7:00:01
)
After ,I will have a datagridview :
Name | ID | Time
Tien | 122 | 7:00:02
Toan |123 |7:00:05
Tuan |124 |7:00:07
I am using C# to program but I don't write this code.Can you help me,please.Thanks you very much
Name | ID | Time
Toan | 123 | 7:00:01
Tien | 122 | 7:00:02
Tuan |124 |7:00:03
Toan |123 |7:00:05
Tuan |124 |7:00:07
I want to use C# and Sql to remove the first row Toan | 123 | 7:00:01 and Tuan |124 |7:00:07 because two rows have same data and if Name is same ,I will delete a row which has old time (Toan | 123 | 7:00:01
and Toan | 123 | 7:00:05 the program will delete Toan | 123 | 7:00:01
)
After ,I will have a datagridview :
Name | ID | Time
Tien | 122 | 7:00:02
Toan |123 |7:00:05
Tuan |124 |7:00:07
I am using C# to program but I don't write this code.Can you help me,please.Thanks you very much
Mahesh ChandRank #1 · 393K pointsPosted Feb 21, 2011, 5:06 AM EST
You can remove a row from a DataSet or a DataTable by using DataTable.Rows[RowIndex].Delete() method. For example,
dataSet1.Tables["Customers"].Rows[0].Delete();
After that, you call
dataSet1.Tables["Customers"].AcceptChanges();
Then you bind dataSet1 to the DataGridView control.
toanhoi bui52 pointsPosted Feb 21, 2011, 5:12 AM EST