mercredi 26 novembre 2014

Why ain't values getting deleted in a table even if DELETE command is working fine?


Vote count:

0




I have developed management system for an organization. I have many datagridviews in my forms. And for every delete operation, i have the same command (IN THERE RESPECTIVE CELL CONTENT CLICK EVENTS) as you could see below. At one place its working just fine and values are getting deleted from tables. But in another table, when i click button in a datagridview named delete so inside cell content click event i am supposed to delete the record of that entity from database. On clicking, row gets removed but when i just open my database, values are still there.


My coide is here:



private void data_grid2_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
// Result's tab's Gridview
int m = 0;
int currentRow = int.Parse(e.RowIndex.ToString());
try
{
string name = data_grid2.CurrentRow.Cells["RollNo"].Value.ToString();
m = int.Parse(name);
}
catch (Exception ex)
{
throw;
}

if (data_grid2.Columns[e.ColumnIndex] == editButton && currentRow >= 0)
{

}

else if (data_grid2.Columns[e.ColumnIndex] == deleteButton && currentRow >= 0)
{
string queryDeleteString = "DELETE * FROM finalResult where RollNo = " + m + "";
OleDbCommand sqlDelete = new OleDbCommand();
sqlDelete.CommandText = queryDeleteString;
sqlDelete.Connection = database;
sqlDelete.ExecuteNonQuery();
string queryString = "SELECT RollNo, RegYear, faculty, program, examNature, finalmarksObt, totalMarks, Percentage FROM finalResult";
loadResults(queryString);

}
}


What could be wrong behind the scene? enter image description here



asked 19 secs ago







Why ain't values getting deleted in a table even if DELETE command is working fine?

Aucun commentaire:

Enregistrer un commentaire