0

I am using the below code for saving data into a MS-Access 2007 table. But it throw a expression as follows:

{"Syntax error (missing operator) in query expression '0','0','0','0','0','0','0','0')'."}

I have attached the code below:

cmd.CommandText = "INSERT INTO Daily_EB_Consumption (EB_S1, EB_S2, EB_S3, EB_S4, EB_S5, EB_Indus, EB_LH, EB_Total, EB_Date) " & _
    " VALUES(" & Me.txt_S1.Text & "','" & _
      Me.txt_S2.Text & "','" & Me.txt_S3.Text & "','" & Me.txt_S4.Text & "','" & _
      Me.txt_S5.Text & "','" & Me.txt_Indus.Text & "','" & Me.txt_LH.Text & "','" & _
      Me.txt_Total.Text & "','" & Me.dt_EB.Value & "')"       

Please anyone help with this error

1 Answer 1

1

You have used the apostrophe but only on the right side. You have to wrap the values in apostrophes:

VALUES('" & Me.txt_S1.Text & "', ...

But you are open for SQL-Injection, so you should use parameters.

using parameters inserting data into access database

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your Help Mr. Tim... Now the code is working properly

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.