Get Mysql Timestamp to textbox with your own format
here is my complete code for it
Code:
Dim conn As New MySqlConnection(connStr)
conn.Open()
Dim reader As MySqlDataReader
Dim cmd_date As New MySqlCommand("SELECT timestamp FROM allmessage WHERE status='sent' ORDER BY ID DESC LIMIT 0, 1", conn)
reader = cmd_date.ExecuteReader
While reader.Read
Dim i As Date = reader.GetDateTime("timestamp")
TextBox2.Text = Format(CDate(i), "yyyy-dd-MM HH:mm:ss")
End While
conn.Close()
declare this function
Public Function GetDateTime(ByVal ordinal As Integer) As DateTime
End Function
Re: Get Mysql Timestamp to textbox with your own format
For all of the reasons in this thread: http://www.vbforums.com/showthread.p...in-the-textbox ... this is considered substandard coding... all it takes is one line:
TextBox1.Text = i.ToString("yyyy-dd-MM HH:mm:ss") ... in fact you can skip using i all together....
Textbox1.Test = reader.GetDateTime("timestamp").ToString("yyyy-dd-MM HH:mm:ss")
Oh... and you'll want to do this with a scalar method... not a reader... you're only returning one date and one date only... use the ExecuteScalar function instead.
-tg