Solved

sql error

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB: Convert 2 dates to specific format 24 48
get row value in vb.net 4 14
Help with preventing downloading a zip file 10 35
Convert datetime to time string 10 19
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

785 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