示例#1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            ProcessList prlist = new ProcessList();

            SqlCommand komut = new SqlCommand("update process  set   NAME='" + comboBox1.Text + "',book='" + comboBox2.Text + "',borrow_time=@borrowedtime,delivery_time=@deliverytime,notes='" + txtNotes.Text + "'where process_id= @test ", con);

            komut.Parameters.AddWithValue("@borrowedtime", borrowedTime.Value.Date);
            komut.Parameters.AddWithValue("@test", prlist.dataGridViewProcessList.CurrentRow.Cells[0].Value.ToString());
            komut.Parameters.AddWithValue("@deliverytime", deliveryTime.Value.Date);
            con.Open();
            komut.ExecuteNonQuery();
            con.Close();
            SqlDataAdapter da = new SqlDataAdapter("Select * from process", con);
            DataSet        ds = new DataSet();

            da.Fill(ds);
            prlist.dataGridViewProcessList.DataSource = ds.Tables[0];

            MessageBox.Show("updated succesfully");
        }