The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
Public Function checkDate(ByVal tbl As String, ByVal AppId As Double, ByVal col As String, ByVal val As String) As Boolean If con.State = ConnectionState.Open Then con.Close() End If Dim valdate As Date = Convert.ToDateTime(val) MsgBox(valdate) Dim i As Integer 'databaseConnection(cmd) Dim cmd As New SqlCommand("select count(*) from " & tbl & " where appid=" & AppId & " and " & col & "<='" & valdate & "'", con) 'cmd.CommandText = "select count(*) from " & tbl & " where appid=" & AppId & " and " & col & "<='" & valdate & "'" 'cmd.CommandType = CommandType.Text MsgBox(cmd.CommandText) con.Open() i = cmd.ExecuteScalar() MsgBox(i) ' Convert.ToInt32(i) If (i > 0) Then Return True Else Return False End If con.Close() End Function
val
DateTime:
DateTime2:
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)