Hi Everyone,
I have an application in which i have to take reports of the transaction done on particular date range
For this I am creating one temp table in which data is inserted and fetched during form load, here is the code
Dim InDate As String
Dim OutDate As String
Dim DtIn As Date
Dim DtOut As Date
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
Regno = ds.Tables(0).Rows(i)(0).ToString()
barcode = ds.Tables(0).Rows(i)(1).ToString()
vehityp = ds.Tables(0).Rows(i)(2).ToString()
vehimodl = ds.Tables(0).Rows(i)(3).ToString()
InDate = ds.Tables(0).Rows(i)(4).ToString()
OutDate = ds.Tables(0).Rows(i)(5).ToString()
DtIn = DateTime.Parse(InDate)
DtOut = DateTime.Parse(OutDate)
diff = DtIn - DtOut
DiffD = diff.Days
DiffH = diff.Hours
DiffM = diff.Minutes
Try
sqlcmd = "Insert Into tmp ([RegistrationNo],[Barcode],[VehicleType],[VehicleModel] , [TranInDate], [TranOutDate], [OutDays], [OutHours], [OutMins]) Values ('" _
+ Regno + "','" + barcode + "','" + vehityp + "','" + vehimodl + "', '" + InDate.ToString() + "', '" + OutDate.ToString() + "', " + DiffD.ToString() + ", " + DiffH.ToString() + ", " + DiffM.ToString() + ")"
cmd.CommandText = sqlcmd
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message, "Messageinst")
End Try
Next
When My InDate is blank it is showing an error as
"String was not recognised as a valid DateTime"
Can anyone help me on how to insert the blank InDate value