Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sql error

Posted on 2013-12-20
1
Medium Priority
?
229 Views
Last Modified: 2013-12-27
this insert statement has a syntax error and I can not spot it.
'this double " after the table name will not go away and I do not see why, the editor insists on putting it back the statement is closed at the bottom

 insertstatement = "INSERT INTO HOURSWORKED  _"  
                        (WORKDATE,STARTTIME,ENDTIME,STARTLUNCH,ENDLUNCH,STARTPERSONEL,ENDPERSONEL,HOURSTHISDAY,PAYEDHRSTHISWEEK,PTODETAIL,PAYEDPTOTHISWEEK,EMPLOYEESOCSEC,WEEKOFYEAR,SYMITARCODE) _
                             VALUES ('" & dateString     & "','" _
                                        & "8:00 AM"      & "','" _
                                        & "5:00"         & "','" _
                                        & "12:00 PM"     & "','" _
                                        & "1:00 PM"      & "','" _
                                        & ""             & "','" _
                                        & ""             & "','" _
                                        & "8.0"          & "','" _
                                        & savehours      & "','" _
                                        & ""             & "','" _
                                        & "0"            & "','" _
                                        & TXBSOCSEC.Text & "','" _
                                        & saveweekcount  & "','" _
                                        & ""             & "')"
                    Dim cmd2 As New OleDb.OleDbCommand(insertstatement, Conworkcounter)
                    cmd2.ExecuteNonQuery()
0
Comment
Question by:javagair
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
acbxyz earned 2000 total points
ID: 39732844
The syntax is wrong. If you want line breaks in your code, you need to close the string at the end of the line and concat all strings together.
I've adjusted the single quotes, it is better to have a pair together in one line. If adding the , within and & outside the double quotes in the old or new line is personal choice.

 insertstatement = "INSERT INTO HOURSWORKED  " & _
"(WORKDATE,STARTTIME,ENDTIME,STARTLUNCH,ENDLUNCH,STARTPERSONEL,ENDPERSONEL,HOURSTHISDAY,PAYEDHRSTHISWEEK,PTODETAIL,PAYEDPTOTHISWEEK,EMPLOYEESOCSEC,WEEKOFYEAR,SYMITARCODE)  VALUES " & _
                                        "('" & dateString     & "'," & _
                                        "'8:00 AM'," & _
                                        "'5:00'," & _
                                        "'12:00 PM'," & _
                                        "'1:00 PM'," & _
                                        "''," & _
                                        "''," & _
                                        "'8.0'," & _
                                        "''," & _
                                        "''," & _
                                        "0," & _
                                        "'" & TXBSOCSEC.Text & "'," & _
                                        "'" & saveweekcount  & "'," & _
                                        "'')"

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question