0

This is my code:
String cmdText = ("UPDATE sinhvien SET Ho= '" + HoSV + "',Ten = '" + TenSV + "', Ngaysinh= '" + dateTimePicker1.Value.ToString("yyyy/MM/dd") + "',Ghichu='" + GhiChu + "',Diemthi = '" + DiemThi + "' WHERE idSinhVien =" dataGridView1.SelectedRows[0].Cells[0].Value.ToString()IDSinhVien);
MySqlCommand cmd = new MySqlCommand(cmdText, constr);
cmd.ExecuteNonQuery();

I cannot update, if i change idsinhvien = int => success. but mysql idsinhvien= varchar => error

3
Contributors
4
Replies
19
Views
3 Years
Discussion Span
Last Post by JerrimePatient
0

change the dateTimePicker1.Value.ToString("yyyy/MM/dd") to dateTimePicker1.Value.ToString("yyyy-MM-dd") and "' WHERE idSinhVien =" dataGridView1.SelectedRows[0].Cells[0].Value.ToString()IDSinhVien)"
to "' WHERE idSinhVien=" + dataGridView1.SelectedRows[0].Cells[0].Value.ToString() +"')"

Note: dataGridView1.SelectionMode must be FullRowSelect.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.