Solved

SQl not inserting date into database

Posted on 2008-06-18
2
164 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 125 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

Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

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 …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

688 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