المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Delete specific rows from database tables



C# Programming
06-24-2012, 03:40 AM
I have dataGridview table, when i click on specific cell in specific column, it searches text from that cell in other database tables and returns single rows. How to delete found rows from those tables?

I got this far:

private void datoru_sarakstsDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)if (e.ColumnIndex == 7) {string a = datoru_sarakstsDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString(); DataRow[] sarakstsRow = datori_database.Tables["datoru_saraksts"].Select("datora_id = '" + a + "'"); sarakstsRow[0].Delete();DataRow[] konfigRow = datori_database.Tables["konfig"].Select("datora_id = '" + a + "'");konfigRow[0].Delete();DataRow[] osRow = datori_database.Tables["operetajsistemas"].Select("datora_id = '" + a + "'");osRow[0].Delete();DataRow[] progRow = datori_database.Tables["programmas"].Select("datora_id = '" + a + "'");progRow[0].Delete();
But when i execute my program and try it, it doesn't delete those rows.

Sorry for my bad english.