|
 |
|
access เออเร่อ Syntax error in statement. แก้ยังไงครับ มี2 อันเลยครับ |
|
 |
|
|
 |
 |
|
คือว่าเขียนโค๊ต เชื่อมต่อกับ access ต้องการ adddata กับ update
แต่ มันเออเร่อ Syntax error in UPDATE statement. กับ Syntax error in INSERT INTO statement.


แก้ยังไงครับ code ดังนี้ครับ
อันนี้โค๊ต AddData
Code (VB.NET)
Public Sub Add_Data()
con.Open()
Dim rs As New OleDb.OleDbCommand("Insert into Tblcost(RoomID,CusName,Month,CusID,Roomprice,Meter_w_before,Meter_w_after,Total_water,Meter_f_before,Meter_f_after,Total_Fine,Battalet,Other,Total) values ('" & RoomID.Text & "' , '" & CusName.Text & "' , '" & Month.Text & "' , '" & CusID.Text & "' , '" & Roomprice.Text & "' , '" & Meter_w_before.Text & "' , '" & Meter_w_after.Text & "' , '" & Total_water.Text & "' , '" & Meter_f_before.Text & "' , '" & Meter_f_after.Text & "' , '" & Total_Fine.Text & "' , '" & Battalet.Text & "' , '" & Other.Text & "' , '" & Total.Text & "')", con)
rs.ExecuteNonQuery()
con.Close()
cuscost()
End Sub
ส่วนอันนี้โค๊ต UPDATE หรือ edit นั้นเองครับ
Code (VB.NET)
Public Sub Update_Data()
con.Open()
Dim rs As New OleDb.OleDbCommand("Update Tblcost set CusName='" & CusName.Text & "', Month='" & Month.Text & "', Roomprice='" & Roomprice.Text & "', Meter_w_before='" & Meter_w_before.Text & "', Meter_w_after='" & Meter_w_after.Text & "' , Total_water='" & Total_water.Text & "' , Meter_f_before='" & Meter_f_before.Text & "' , Meter_f_after='" & Meter_f_after.Text & "' , Total_Fine='" & Total_Fine.Text & "' , Battalet='" & Battalet.Text & "' , Other='" & Other.Text & "' , Total='" & Total.Text & "' where CusID='" & CusID.Text & "' or RoomID='" & RoomID.Text & "' ", con)
rs.ExecuteNonQuery()
con.Close()
cuscost()
End Sub
อันนี้ไฟล์ database
http://www.upload-thai.com/download.php?id=8d1f43f52a7ad34b3b78e42b61c48357
ส่วนอันนี้โค๊ต โมดูลที่ใช้
Code (VB.NET)
Module Module1
Public con As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database3.mdb")
End Module
Tag : .NET, Ms Access, VBScript, VB.NET, Windows

|
|
 |
 |
 |
 |
Date :
2013-12-14 21:48:24 |
By :
wanlop8822 |
View :
1337 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 00
|