搜索时单元格值返回其原始值

时间:2017-10-01 02:51:51

标签: c# datagridview

您好GoodMorning我实际上遇到了datagridview

的问题

- 借书后,价值将变为0 Datagrid View With A Zero

- 问题是,当我再次开始搜索那本书时,它显示的值为1,这将允许我再次借用那本书

enter image description here

  • 这是我的复习代码

            connection.Open();
            OleDbCommand command = new OleDbCommand();
            command.Connection = connection;
            string query = "select *from Books";
            command.CommandText = query;
    
            OleDbDataAdapter da = new OleDbDataAdapter(command);
            DataTable dt = new DataTable();
            da.Fill(dt);
            dataview6.DataSource = dt;
            connection.Close();
    

这是我借书的代码

private void borrow()
    {
        try
        {
            connection.Open();
            OleDbCommand cmd = new OleDbCommand();
            cmd.Connection = connection;
            cmd.CommandText = "UPDATE Books Set Copies = Copies -1 WHERE BOOK_NUMBER = " + bkn_num.Text + "";
            cmd.ExecuteNonQuery();
            MessageBox.Show("Book Has Been Borrowed");
            connection.Close();
        }
        catch (Exception ex)
        {

        }

    }

0 个答案:

没有答案