Solved

sql error

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Encryption Decryption in Oracle 12 107
Code enhancement 5 22
More on Time zones in vb 2010 12 37
I need help making a collection from a class in VB.Net 3 26
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now