RADDateinput error

5 posts, 1 answers
  1. L
    L avatar
    298 posts
    Member since:
    Apr 2008

    Posted 02 May 2011 Link to this post

    hi

    I have a DateInput and i have the date format set to dd/MM/yyyy. I have also keyed in a date as 16/09/1970 and my table field DateOfBirth is of Date dataype in MSSQL.

    But it just kept giving me this error "String was not recognized as a valid DateTime."

    What is wrong? thanks
  2. Jose
    Jose avatar
    49 posts
    Member since:
    Aug 2008

    Posted 02 May 2011 Link to this post

    Hi L.

    Could you paste the code here to check it out?

    thanks.
    Jose
  3. L
    L avatar
    298 posts
    Member since:
    Apr 2008

    Posted 02 May 2011 Link to this post

    hi

    here is my code:

    Sub methodA(byVal DOB as Date)

    sqlcmd.Parameters.Add(New SqlParameter("@DOB", SqlDbType.Date)).Value = DOB
    ExecuteNonQuery

    End Sub

    methodA(txtDOB.Text)


    the txtDOB is a radDateInput and the DOB is a Date datatype in a table field. Thanks

  4. Answer
    Jose
    Jose avatar
    49 posts
    Member since:
    Aug 2008

    Posted 03 May 2011 Link to this post

    Hi L.

    Normally you would call something like:

    methodA(txtDOB.SelectedDate.Value)

    The reason is that the property "Text" will return the text representation of the date while SelectedDate will return the selected date as a nullable DateTime. Most likely you will also need to check wether txtDOB.SelectedDate.HasValue is true and return txtDOB.SelectedDate.Value.

    Let me know if that helped. (and mark it as answer ;) )

    Jose
  5. L
    L avatar
    298 posts
    Member since:
    Apr 2008

    Posted 03 May 2011 Link to this post

    hi Jose

    thanks a lot. It is working fine now. Thanks
Back to Top