Solved

sql error

Posted on 2013-12-20
1
224 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 500 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

Independent Software Vendors: 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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…

734 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