trying to parse a string into a date

  • Hi everyone,

    one of my columns in my sql-db is type of date

    the user inputs the date as a string and then the program converts it to a type date.

    this is what i have so far....

    Dim SD As String = "01/01/2263"

    Dim oDate As DateTime

    oDate = DateTime.Parse(SD)

    If IsDate(oDate) Then

    MsgBox("IsDate", MsgBoxStyle.Information, oDate)

    End If

    the above is a test to make sure the string (IsDate) 🙂

    i add a new row to the db

    ' with the "Nothing" word that Column will be blank

    Dim row As String() = New String() {"Someday", Nothing, Nothing, "Somewhere", "10", "339.64", "203.67", "700.67"}

    DataGridView1.Rows.Add(row)

    then i add the converted string to the row...

    DataGridView1.Rows(0).Cells(1).Value = oDate

    when i upload to the sqldb , sql tells me the the string is {"Failed to convert parameter value from a String to a DateTime."}

    any help would be nice..

    rdgs

  • Quick suggestion, use the ToString() method

    😎

    DataGridView1.Rows(0).Cells(1).Value = oDate.ToString()

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply