Solved

SQl not inserting date into database

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Syntax 24 54
MS SQL GROUP BY 6 82
calculate days away 11 30
SQL query 7 22
'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 …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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