Solved

SQl not inserting date into database

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

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

Suggested Solutions

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

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