Hi, I have this question about how to retrieve a column with DateTime from MySQL as String and put the data in a textbox.
:| So I've been using something like this...
Private Function check_ResitDate_ResitNumber()
Dim SQLquery As String
Dim rrnRD As OdbcDataReader
Dim DiTi As DateTime
SQLquery = "SELECT ResitNom, ResitDate, SUBSTRING(ResitTime,12,5) AS RTime " & _
"FROM TableReceipt " & _
"WHERE ResitNom = '" & Me.txtResitNom.Text & "' " & _
"AND ResitDate = '" & CSQLDate(Me.dtpResitDate.Value) & "' "
Dim rCmd As New OdbcCommand(SQLquery, connCounter)
'connCounter has been declared as a database connection in another main module
rrnRD = rCmd.ExecuteReader()
If rrnRD.HasRows Then
DiTi = Format(rrnRD.Item("RTime"), "HH:mm")
Me.txtWaktuResit.Text = DiTi
End If
rrnRD.Close()
End Function
But it doesnt work. It gives me this error:
System.InvalidCastException: Specified cast is not valid.
at Microsoft. VisualBasic.Strings.Format(Object Expression, String Style)
at [blahblahblah] line [###]
The MySQL data for column "ResitTime" looks like this:
2011-01-07 15:02:07
I want to use this to cross reference with other table in other database, but to do that i need to copy the data into a textbox as string or a datetimepicker as datetime. But string would be more convenient. :p
I appreciate the help, thank you.