Saving date from DatePicker to sql server

2 posts, 0 answers
  1. Clive Hoggar
    Clive Hoggar avatar
    348 posts
    Member since:
    Nov 2008

    Posted 22 Nov 2009 Link to this post

    I am having trouble saving a date from the date picker, and it seems that this is the line 
    causes a syntax issue:

    objCommand.Parameters.Add("@SermonDate", SqlDbType.DateTime).Value = RadDatePicker1.SelectedDate.Value
     
    The database column type is DateTime (but I also tried just Date)

    I have tried a few variations on this code but I still get the error message "syntax error' near 'SermonDate'" .
    There always seem to be issues when it comes to saving a date in a database!

    What am I doing wrong!

    Thanks

    Clive




  2. Clive Hoggar
    Clive Hoggar avatar
    348 posts
    Member since:
    Nov 2008

    Posted 22 Nov 2009 Link to this post

    OK problem solved. In fact it was a missing "," after the previous parameter that I just did not spot!

    Clive
Back to Top