I have a text box on an ASP.net page that will be used to enter a time that will be stored in a SQL 2008 Time format data field. Using the code below I get the message: "Failed to convert parameter value from a String to a TimeSpan"
VB.Net does not seem to have a variable type to go with SQL 2008's new Time type.
Can anyone suggest how to get this to work... Change from string to another type on the vb.net side... change the Data.SqlDBType.Time to something else?
More info: It works if I try to save any of the following: 12:45, 22:00, etc. It does not work if I try to save 12:45PM. I can make it work if I use 24 hour format, but I wonder if there's a way to save it using AM/PM?
Dim strHoseTestOrRepairTime As String = Nothing
If Len(Trim(Me.textTestOrRepairTime.Text)) > 0 Then
strHoseTestOrRepairTime = Trim(Me.textTestOrRepairTime.Text)
strHoseTestOrRepairTime = "00:00"
Dim myParameterTestOrRepairTime As New SqlParameter("@CHTRTime", Data.SqlDbType.Time)
myParameterTestOrRepairTime.Direction = Data.ParameterDirection.Input
myParameterTestOrRepairTime.Value = strHoseTestOrRepairTime