string myQuery = "DELETE FROM Child WHERE ChildID = " + int.Parse(DropDownList1.SelectedValue) + "";
OleDbCommand myCommand = new OleDbCommand(myQuery, myConnection);
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
Label2.Text = "Done! " + DropDownList1.SelectedValue + " Successful remove";
}
catch (Exception ex)
{
Label2.Text = "Exception in DBHandler" + ex;
}
finally
{
myConnection.Close();
}
}
}
ChildID
column 是一个自动编号的主键。
错误的sql查询?
从数据库中删除选定的下拉列表