...

View Full Version : help inserting date into SQL DB



aktiv
10-29-2010, 09:09 PM
i have a form that collects the date an inserts it into sql db. The form has 3 text fields one for month, one day and one for year.

The problem is that when the date is being inserted into the database it is not inserting the proper values.

the sql code is below:




strSql &= ", crsCity = '" & dbSafe(Request.Form("city")) & "', crsDate = " & (Request.Form("yr")) & "-" & (Request.Form("mo")) & "-" & (Request.Form("day")) & ""



If I choose the follow date on the form, 12/31/2010 it inserts the following into the DB, 5/22/1905

aktiv
10-30-2010, 12:06 AM
ok, solved it... code is below:




crsDate = '" & (Request.Form("yr")) & "-" & (Request.Form("mo")) & "-" & (Request.Form("day")) & "'"



notice the single quotes they are bolded

accwebworks
11-02-2010, 07:53 PM
You really should be using SqlParameters to pass values with your queries.
If you dynamically append them you are vulnerable to sql injection attacks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum