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

x
?
Solved

SQl not inserting date into database

Posted on 2008-06-18
2
Medium Priority
?
166 Views
Last Modified: 2010-03-20
I keep getting the error
Line 1: Incorrect syntax near '6/18/2008'.

It started when I put in the date field.  I just want todays date inserted into the database in the dtpayPaid column but what ever way I change I get different errors, what is the correct syntax.  In my sql 2000 database I have it as a datetime field.

sql = "INSERT tblSADPay (intUicId, strSSN, strVendorNum, strBatchNum, strPGYrs, strRank, strNumDays, strPayPeriod, strbasePay,  strDiffPay, strhousing, strrations, strTotalentitlement, strFTWH, strTTWH, strMiles, strMilesPay, strTotalCheck, dtPayPaid)  VALUES (" & uicID & ", '" & lblSSN.Text & "', '" & txtVendor.Text & "', '" & ddlbatchnum.SelectedValue & "',  '" & lblPayGrYrs.Text & "', '" & lblRank.Text "',  '" & lblDutyDays.Text & "', '" & lblPeriodDuty.Text & "', '" & lblBasePay.Text & "',  '" & lblDiffPay.Text & "', '" & lblHouseAllow.Text & "', '" & lblRations.Text & "', '" & lblTotalEntitlement.Text & "',  '" & lblFTWH.Text & "', '" & lblTotalWH.Text & "', '" & lblMiles.Text & "', '" & lblMilesPay.Text & "', '" & lblTotalCheck.Text & "') '" & Date.Today() & "'"
0
Comment
Question by:kdeutsch
[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
2 Comments
 
LVL 16

Accepted Solution

by:
brad2575 earned 500 total points
ID: 21812468
I beleive the problem is that you do not have a closing ")" at the end of your query for the values so you need to do the following.

If this does not fix it then can you post the query after it is built?  i.e. with the values you are inserting and not the fields you are using?
sql = "INSERT tblSADPay (intUicId, strSSN, strVendorNum, strBatchNum, strPGYrs, strRank, strNumDays, strPayPeriod, strbasePay,  strDiffPay, strhousing, strrations, strTotalentitlement, strFTWH, strTTWH, strMiles, strMilesPay, strTotalCheck, dtPayPaid)  VALUES (" & uicID & ", '" & lblSSN.Text & "', '" & txtVendor.Text & "', '" & ddlbatchnum.SelectedValue & "',  '" & lblPayGrYrs.Text & "', '" & lblRank.Text "',  '" & lblDutyDays.Text & "', '" & lblPeriodDuty.Text & "', '" & lblBasePay.Text & "',  '" & lblDiffPay.Text & "', '" & lblHouseAllow.Text & "', '" & lblRations.Text & "', '" & lblTotalEntitlement.Text & "',  '" & lblFTWH.Text & "', '" & lblTotalWH.Text & "', '" & lblMiles.Text & "', '" & lblMilesPay.Text & "', '" & lblTotalCheck.Text & "') '" & Date.Today() & "')"

Open in new window

0
 

Author Comment

by:kdeutsch
ID: 21812534
Ah I see what I did, I forgot to put in the end bracket after the date field.  The one before it needs to come out though.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

618 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