我在我的数据库中使用 sql server
这是代码
private void btnDelete_Click(object sender, EventArgs e)
{
try
{
//GlobalClass.dt.Rows[rowId].Delete();
//GlobalClass.adap.Update(GlobalClcass.dt);
cDatabaseSQLServer.Delete("satuan", "WHERE id = " + rowId + "");
//this.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
public bool Delete(String tableName, String where)
{
switch (sqlType)
{
case DATABASE_SQL_TYPE.DATABASE_SQL_TYPE_SQLITE:
return cSQLite.Delete(tableName, where);
case DATABASE_SQL_TYPE.DATABASE_SQL_TYPE_MSSQL:
return cSQL.Delete(tableName, where);
}
return false;
}
public bool Delete(String tableName, String where)
{
Boolean returnCode = true;
try
{
this.ExecuteNonQuery(String.Format("delete from {0} where {1};", tableName, where));
}
catch (Exception fail)
{
MessageBox.Show(fail.Message);
returnCode = false;
}
return returnCode;
}
当我调试应用程序时,删除不起作用并且数据仍然存在于 datagridview 中,如何解决?