Dim objConn As New MySqlConnection Dim objCmd As New MySqlCommand Dim objDA As New MySqlDataAdapter Dim ds As DataSet Dim sb As New StringBuilder Dim d As Date Try objConn.ConnectionString = "server=localhost;database=xxx;uid=xxx;pwd=xxx;AllowZeroDateTime=True;ConvertZeroDateTime=True" objConn.Open() ds = New DataSet("MyDataSet") objDA.SelectCommand = New MySqlCommand objDA.SelectCommand.Connection = objConn objDA.SelectCommand.CommandText = "select datecolumn from datatable where ID = 1" objDA.Fill(ds, "tbl") objConn.Close() d = CDate(ds.Tables("tbl").Rows(0)("datecolumn")) sb.Append(String.Format("{0:dd-MMM-yyyy}", d)) Catch ex As Exception If objConn.State = ConnectionState.Open Then objConn.Close() sb.Append(ex.Message) End Try
Conversion from type 'MySqlDateTime' to type 'Date' is not valid.
Dim d2 As DateTime = DateTime.Parse(ds.Tables("tbl").Rows(0)("datecolumn").ToString()) sb.Append(String.Format("{0:dd-MMM-yyyy}", d2))
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)