Solved

sql error

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

18 Experts available now in Live!

Get 1:1 Help Now