如何基于datagridview按钮单击的选择更新datagridview行

时间:2019-06-17 10:57:15

标签: c#

如何通过单击datagridview按钮来更新datagridview行。

代码

Connect_Database.con.Close(); //opening connection
Connect_Database.con.Open(); //closing connection

string qry = "update checkin set Checkin_status =@Checkin_status where CheckIn_Code= '" + dgCheck_Out.SelectedRow.Cells [0].Value  + "' ";
cmd = new SqlCommand(qry, Connect_Database.con);
cmd.Parameters.AddWithValue("@Checkin_status", "Check Out");

int row = cmd.ExecuteNonQuery();
if (row > 0)
{
    MessageBox.Show(string.Format("Guest Sucessfully Checked Out");
}

0 个答案:

没有答案