|
 |
|
แก้ไขข้อมูลไม่ได้ แก้ไขแล้วกด save โปรแกรมแสดง MessageBox ขึ้น "Duplicate entry '(id)' for key 1" |
|
 |
|
|
 |
 |
|
นี่เป็น Code Insert ครับ
Code (C#)
if (txtcusid.Text != string.Empty && txtname.Text != string.Empty && txtqueue.Text != string.Empty && comgarage.Text != string.Empty)
{
int num;
if (!Int32.TryParse(txtcusid.Text, out num))
{
MessageBox.Show("กรอกข้อมูลที่เป็นตัวเลขเท่านั้น!", "ตรวจสอบข้อมูล", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
String connString = "datasource=localhost; port=3306; username=root; Password=1234";
string Query = "INSERT INTO customer (cus_id, cus_name, queue, park_id) VALUES ('" + txtcusid.Text + "','" + txtname.Text + "','" + txtqueue.Text + "','" + comgarage.Text + "')";
MySqlConnection conDatabase = new MySqlConnection(connString);
MySqlCommand cmdDatabase = new MySqlCommand(Query, conDatabase);
MySqlDataReader myReader;
try
{
conDatabase.Open();
myReader = cmdDatabase.ExecuteReader();
MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "บันทึกสำเร็จ", MessageBoxButtons.OK, MessageBoxIcon.Information);
while (myReader.Read())
{
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
groupBox1.Enabled = false;
btsave.Enabled = false;
// Refresh data
load_Showall();
// Clear Data in GropBox
clear();
}
else
{
MessageBox.Show("ข้อมูลว่าง", "ไม่มีข้อมูล", MessageBoxButtons.OK, MessageBoxIcon.Information);
groupBox1.Enabled = false;
btsave.Enabled = false;
}
}
|
 |
 |
 |
 |
Date :
2013-06-16 16:11:39 |
By :
Programmer yajok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|