private void dataGridSearch_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex == 1) { return; }
textBox1.Text = dataGridSearch.Rows[e.RowIndex].Cells[1].Value.ToString();
textBox2.Text = dataGridSearch.Rows[e.RowIndex].Cells[2].Value.ToString();
textBox3.Text = dataGridSearch.Rows[e.RowIndex].Cells[3].Value.ToString();
textBox4.Text = dataGridSearch.Rows[e.RowIndex].Cells[4].Value.ToString();
textBox5.Text = dataGridSearch.Rows[e.RowIndex].Cells[5].Value.ToString();
}
private void button4_Click_1(object sender, EventArgs e)
{
try {
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\\Project\\0\\0\\0\\Database.mdb");
conn.Open();
OleDbCommand comm = new OleDbCommand();
comm.Connection = conn;
comm.CommandText = "UPDATE tb_Student SET Title='" + textBox1.Text.Trim() + "',Fname='" + textBox2.Text.Trim() + "',Lname='" + textBox3.Text.Trim() + "',Behaviour='" + textBox4.Text.Trim() + "',Day='" + textBox5.Text.Trim() + "'";
comm.ExecuteNonQuery();
MessageBox.Show("แก้ไขข้อมูลเรียบร้อย");
conn.Close();
}
catch(Exception ex)
{
MessageBox.Show("ผิดพลาด" + ex);
}
}
แก้ไขข้อมูลแล้วบันทึกลงฐานข้อมูลไม่ได้ครับ C# ACCESS
{
if (e.RowIndex == 1) { return; }
textBox1.Text = dataGridSearch.Rows[e.RowIndex].Cells[1].Value.ToString();
textBox2.Text = dataGridSearch.Rows[e.RowIndex].Cells[2].Value.ToString();
textBox3.Text = dataGridSearch.Rows[e.RowIndex].Cells[3].Value.ToString();
textBox4.Text = dataGridSearch.Rows[e.RowIndex].Cells[4].Value.ToString();
textBox5.Text = dataGridSearch.Rows[e.RowIndex].Cells[5].Value.ToString();
}
private void button4_Click_1(object sender, EventArgs e)
{
try {
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\\Project\\0\\0\\0\\Database.mdb");
conn.Open();
OleDbCommand comm = new OleDbCommand();
comm.Connection = conn;
comm.CommandText = "UPDATE tb_Student SET Title='" + textBox1.Text.Trim() + "',Fname='" + textBox2.Text.Trim() + "',Lname='" + textBox3.Text.Trim() + "',Behaviour='" + textBox4.Text.Trim() + "',Day='" + textBox5.Text.Trim() + "'";
comm.ExecuteNonQuery();
MessageBox.Show("แก้ไขข้อมูลเรียบร้อย");
conn.Close();
}
catch(Exception ex)
{
MessageBox.Show("ผิดพลาด" + ex);
}
}