|
|
|
เพิ่มข้อมูลลงฐานข้อมูลไม่ได้ครับ โปรแกรมแจ้งว่า Failed to convert parameter value from a String to a DateTime. |
|
|
|
|
|
|
|
Code (C#)
private void saceCustomer_Click(object sender, EventArgs e)
{
OleDbConnection OleDbConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=SparesStore.mdb;");
OleDbCommand OleDbCmd = new OleDbCommand();
OleDbCmd.Connection = OleDbConn;
OleDbCmd.CommandText = "INSERT INTO Customer VALUES (customer_id, customer_name, id_card, address, delivery_adress, telephone, mobile, fax, email, customer_type)";
OleDbConn.Open();
OleDbCmd.Parameters.Add("@รหัสลูกค้า", OleDbType.VarChar).Value = customer_id.Text;
OleDbCmd.Parameters.Add("@ชื่อ", OleDbType.VarChar).Value = customer_name.Text;
OleDbCmd.Parameters.Add("@เลที่บัตรประชาชน", OleDbType.VarChar).Value = id_card.Text;
OleDbCmd.Parameters.Add("@ที่อยู่", OleDbType.Date).Value = address.Text;
OleDbCmd.Parameters.Add("@สถานที่จัดส่ง", OleDbType.VarChar).Value = delivery_adress.Text;
OleDbCmd.Parameters.Add("@โทรศัพท์", OleDbType.VarChar).Value = telephone.Text;
OleDbCmd.Parameters.Add("@มือถือ", OleDbType.VarChar).Value = mobile.Text;
OleDbCmd.Parameters.Add("@แฟกซ์", OleDbType.VarChar).Value = fax.Text;
OleDbCmd.Parameters.Add("@Email", OleDbType.VarChar).Value = email.Text;
OleDbCmd.Parameters.Add("@ประเภทลูกค้า", OleDbType.VarChar).Value = customer_type.Text;
OleDbCmd.ExecuteNonQuery();
OleDbConn.Close();
MessageBox.Show("บันทึกสำเร็จ");
}
Tag : .NET, Ms Access, Win (Windows App), C#
|
|
|
|
|
|
Date :
2012-03-21 16:58:38 |
By :
DevilMonkeyZ |
View :
1105 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|