Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2009
    Location
    Indiana
    Posts
    37
    Thanks
    11
    Thanked 1 Time in 1 Post

    Exclamation help inserting date into SQL DB

    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:

    Code:
     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

  • #2
    New Coder
    Join Date
    Aug 2009
    Location
    Indiana
    Posts
    37
    Thanks
    11
    Thanked 1 Time in 1 Post

    Resolved

    ok, solved it... code is below:

    Code:
    crsDate = '" & (Request.Form("yr")) & "-" & (Request.Form("mo")) & "-" & (Request.Form("day")) & "'"
    notice the single quotes they are bolded

  • #3
    New Coder
    Join Date
    Mar 2010
    Location
    nyc
    Posts
    31
    Thanks
    0
    Thanked 1 Time in 1 Post
    You really should be using SqlParameters to pass values with your queries.
    If you dynamically append them you are vulnerable to sql injection attacks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •