 |
|
insert into ลงใน SQL Error Incorrect syntax near '11'. คิดว่าหน้าจะเป็นเพราะใช้ DateTimePicker ผิดไวยกรณ์ แก้ไขยังไงดีครับ
ตัวที่ใช้ DateTimePicker
1.dtpPersent datatype = datetime
2.dtpStart datatype = datetime
3.dtpEnd datatype = datetime
Database ใช้เป็น
1.dtpPersent datatype = datetime
2.dtpStart datatype = datetime
3.dtpEnd datatype = datetime
Code (C#)
SqlConnection Connection = new SqlConnection("Server=big-PC;Uid=sa;PASSWORD=2003;database=IT Service;Max Pool Size=400;Connect Timeout=600;");
Connection.Open();
SqlCommand cmd = new SqlCommand(" insert into IT_Operation( dtpPersent, txtOperation, dtpStart, dtpEnd, txtOfficer, txtManager) VALUES (" + Convert.ToDateTime(dtpPersent.Value) + ",'" + txtOperation.Text + "'," + Convert.ToDateTime(dtpStart.Value) + "," + Convert.ToDateTime(dtpEnd.Value) + ",' " + txtOfficer.Text + "',' " + txtManager.Text + "')", Connection);
cmd.ExecuteNonQuery();
Connection.Close();
MessageBox.Show("Insertion successfully done");
Tag : .NET, C#
|
|
 |
 |
 |
 |
Date :
2012-03-29 11:44:34 |
By :
prykazip69 |
View :
3436 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |