I import excel file and show on datagridview
I want insert all row datagridview to mysql. But i receive error: Incorrect date value:'11/14/1991 12:00:00 AM' for column 'Ngaysinh at row 1.
Mysql : i using date : yyyy/mm/dd
datagridview show : mm/dd/yyyy. i don't know error: '12:00:00AM ' ????
column 3,5 : date
This is my code:
for (int i = 0; i < dataGridView1.Rows.Count; i++) // dòng
{
string str = "Server=localhost;Port=3306;Database=sinhvien;Uid=root;Pwd=1234;";
MySqlConnection constr = new MySqlConnection(str);
constr.Open();
String cmdText = "INSERT INTO danhsachsinhvien (idSinhVien, Ho, Ten, Ngaysinh, Ghichu,Ngaythi ,Buoithi) VALUES ('"
+ dataGridView1.Rows[i].Cells[0].Value + "','"
+ dataGridView1.Rows[i].Cells[1].Value + "','"
+ dataGridView1.Rows[i].Cells[2].Value + "','"
+ dataGridView1.Rows[i].Cells[3].Value + "','"
+ dataGridView1.Rows[i].Cells[4].Value + "','"
+ dataGridView1.Rows[i].Cells[5].Value + "','"
+ dataGridView1.Rows[i].Cells[6].Value + "')";
MySqlCommand cmd = new MySqlCommand(cmdText, constr);
cmd.ExecuteNonQuery();
}