 |
|
Incorrect syntax near the keyword 'WHERE'. ช่วยดูหน่อยคับ |
|
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub Btnupdate_Click() Handles Btnupdate.Click
If TextID.Text = "" Or IsDataComplete() = False Then
Exit Sub
End If
Dim s As String
If Not (PictureBox1.Image Is Nothing) Then
s = ",Picture = @pic"
Else
s = ""
End If
sql = "UPDATE Employee SET Emp_Name = @name,Emp_Las = @last,Emp_Age = @age,Emp_Num = @num,Emp_Add = @add & s"
sql = "WHERE Emp_ID = @id"
command.Parameters.Clear()
command.CommandText = sql
command.Parameters.AddWithValue("@name", Textname.Text)
command.Parameters.AddWithValue("@last", Textlats.Text)
command.Parameters.AddWithValue("@age", Textage.Text)
command.Parameters.AddWithValue("@num", Textnum.Text)
command.Parameters.AddWithValue("@add", Textadd.Text)
command.Parameters.AddWithValue("@id", TextID.Text)
If Not (PictureBox1.Image Is Nothing) Then
Dim byteArr() As Byte = ReadImage()
command.Parameters.AddWithValue("pic", byteArr)
End If
If command.ExecuteNonQuery() = 1 Then
MessageBox.Show("บันทึกการเปลี่ยนแปลงแล้ว")
UpdateBinding()
Else
MessageBox.Show("เกิดข้อผิดพลาด")
End If
End Sub
คือผมจะ update ข้อมูล แต่ติดอยู่ตรงจะอัพเดทตัวEmp_ID ที่เป็นตัว IDENTITY มัน Errorตรงเนียคับ ช่วยดูหน่อยคับ
Tag : .NET, VS 2010 (.NET 4.x)
|
|
 |
 |
 |
 |
Date :
2013-02-18 12:02:26 |
By :
tumsonicsnk |
View :
913 |
Reply :
8 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เครื่องหมาย =
|
 |
 |
 |
 |
Date :
2013-02-18 12:22:17 |
By :
ห้ามตอบเกินวันละ 2 กระทู้ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าแก้ที่ = แล้วก็จะ error อีกทีเพราะ space
|
 |
 |
 |
 |
Date :
2013-02-18 12:23:02 |
By :
ห้ามตอบเกินวันละ 2 กระทู้ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Real World Application
PL ----> BLL ----> DAL
...
Btnupdate.Click() Parameter(ByVal Button As Button) Parameter(Byval Button As Button)
If txtSexCode = "" Then Insert/Update/Delete from tableSEX
... Insert into tableXXX (fucTime, Price) Values ( 3, 1,500 x 3)
End If
...
|
 |
 |
 |
 |
Date :
2013-02-18 13:10:42 |
By :
ผ่านมา |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
.
|
ประวัติการแก้ไข 2013-02-20 10:30:40
 |
 |
 |
 |
Date :
2013-02-18 17:41:20 |
By :
คนงานตัดอ้อย |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมเคยเขียนแบบนี้อ่ะครับ
sql = "UPDATE .................................."
sql &= "WHERE ................................;"
ไม่รู้ว่าเกี่ยวกับหรือเปล่านะครับ 
|
 |
 |
 |
 |
Date :
2013-02-18 18:08:09 |
By :
golfkub |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณสำหรับข้อมูลคับ
|
 |
 |
 |
 |
Date :
2013-02-18 19:06:22 |
By :
tumsonicsnk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
string sql = "UPDATE Employee SET Emp_Name = @name,Emp_Las = @last,Emp_Age = @age,Emp_Num = @num,Emp_Add = @add & s"
sql += " WHERE Emp_ID = @id"
|
 |
 |
 |
 |
Date :
2013-02-20 09:41:54 |
By :
eibwenmai |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
sql = "UPDATE Employee SET Emp_Name = @name,Emp_Las = @last,Emp_Age = @age,Emp_Num = @num,Emp_Add = @add & s"
sql += "WHERE Emp_ID = @id"
|
 |
 |
 |
 |
Date :
2013-02-20 09:45:19 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|