这是我的功能。
private void btnUpdate_Click(object sender, EventArgs e)
{
try
{
con.Open();
cmd = new SqlCommand("update myEXPENSES set Detail= '" + txtDetail.Text
+ "',Price='" + txtPrice.Text + "'
where Detail='" + txtDetail.Text + "'", con);
cmd.ExecuteNonQuery();
MessageBox.Show("Data has been updated");
con.Close();
displayData();
}
catch (Exception)
{
}
}