|
|
|
พบปัญหา syntax error in INSERT INTO Statement ครับ [VB.net] |
|
|
|
|
|
|
|
Code (VB.NET)
เป็น Button เพิ่ม Record ลงใน Access ครับ จับ Catch ได้ว่า "syntax error in INSERT INTO Statement"
ขอความกรุณาด้วยครับ T.T
Private Sub btn_okitemout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_okitemout.Click
Dim con As New OleDbConnection
Dim directory As String = My.Application.Info.DirectoryPath
Dim strConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & directory & "\DB-SUPORD4.mdb;Jet OLEDB:Database Password=;"
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
Dim dt As New DataTable
Dim bd As New BindingSource
Dim strsql As String
Dim objConnx As New OleDbConnection
Dim objCmdx As New OleDbCommand
Dim qt As Integer = Convert.ToInt32(txt_qt.Text)
Dim qtokitemout As Integer = Convert.ToInt32(txt_qtokitemout.Text)
If qtokitemout > qt Then
frm_additemx.Show()
txt_qtokitemout.Text = ""
txt_qtokitemout.Focus()
Exit Sub
End If
strsql = "INSERT INTO tbl_itemout_status (itemout_status_billno," & _
"itemout_status_getbillno," & _
"itemout_status_uu," & _
"itemout_status_uugive," & _
"itemout_status_want," & _
"itemout_status_qtokitemout," & _
"itemout_status_name," & _
"itemout_status_nameth," & _
"itemout_status_nsn," & _
"itemout_status_nsn1," & _
"itemout_status_nsn2," & _
"itemout_status_type," & _
"itemout_status_datex," & _
"itemout_status_userx," & _
"itemout_status_sto," & _
" VALUES " & _
"('" & Me.txt_billno.Text & "'," & _
"'" & Me.txt_getbillno.Text & "'," & _
"'" & Me.txt_uu.Text & "'," & _
"'" & Me.txt_uugive.Text & "'," & _
"'" & Me.txt_wantx.Text & "'," & _
"'" & Me.txt_qtokitemout.Text & "'," & _
"'" & Me.txt_name.Text & "'," & _
"'" & Me.txt_nameth.Text & "'," & _
"'" & Me.txt_nsn.Text & "'," & _
"'" & Me.txt_nsn1.Text & "'," & _
"'" & Me.txt_nsn2.Text & "'," & _
"'" & Me.txt_type.Text & "'," & _
"'" & Me.txt_date.Text & "'," & _
"'" & Me.txt_xxx.Text & "'," & _
"'" & Me.txt_sto.Text & "')"
objConnx.ConnectionString = strConnString
objConnx.Open()
Select Case MsgBox("ทำการตัดจ่าย สป. " + txt_name.Text & vbNewLine & "จำนวน " + txt_qtokitemout.Text + " EA", MsgBoxStyle.Exclamation + MsgBoxStyle.OkCancel, "WARNING")
Case MsgBoxResult.Ok
With objCmdx
.Connection = objConnx
.CommandText = strsql
.CommandType = CommandType.Text
End With
Try
objCmdx.ExecuteNonQuery()
txt_id.Clear()
txt_nameth.Clear()
txt_name.Clear()
txt_nsn.Clear()
txt_nsn1.Clear()
txt_nsn2.Clear()
txt_type.Clear()
txt_qt.Clear()
txt_billno.Clear()
txt_getbillno.Clear()
txt_uu.Clear()
txt_uugive.Clear()
txt_qtokitemout.Clear()
rdo_dl.Checked = False
rdo_SP.Checked = False
rdo_pll.Checked = False
rdo_asl.Checked = False
Catch ex As Exception
MsgBox(ex.Message)
End Try
Case MsgBoxResult.Cancel
'MsgBox("NO Clicked.")
End Select
objConnx.Close()
objConnx = Nothing
End Sub
Tag : .NET, Ms Access, Win (Windows App), VB.NET, VS 2010 (.NET 4.x)
|
ประวัติการแก้ไข 2020-03-17 15:49:35 2020-03-17 15:50:06
|
|
|
|
|
Date :
2020-03-17 15:47:53 |
By :
garzorio7 |
View :
642 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
, เกิน
) หาย
แต่ผมจะยังไม่บอกว่าจุดไหนให้ไปหาเอาเอง
เวลาเขียนคำสั่งแล้วมีฟิลด์เยอะจงอย่าลืม รูปแบบของคำสั่ง SQL
ใล่ดูดี ๆ แล้วจะพบข้อผิดพลาดเอง
|
|
|
|
|
Date :
2020-03-18 08:01:38 |
By :
อ่าวไทย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แนะนำนะครับ
เบื้องต้นลองหัด Debug
ถ้าคิดว่า command SQL ผิด ให้ไปลอง ใน sql จริง ๆ ก่อนค่อยเอามาใช้นะครับ
ง่ายๆลองพยายามดูครับ
|
|
|
|
|
Date :
2020-03-18 08:39:53 |
By :
2127832830566218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แก้ไขใช้ได้แล้วครับ ขอบคุณทั้ง 2 ท่านมากๆครับ
|
|
|
|
|
Date :
2020-03-18 13:00:55 |
By :
garzorio7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|