weird datetime problem
Posted: Wed Aug 08, 2007 10:07 pm
Hello,
I'm having a strange problem with date-time data. I'm reading the data from a MySQL database and displaying it as a scatter plot. I can get the x-axis to display as numbers, but when I try to display dates, I get values in the 1900's. The actual data from the database displays properly (recent dates) in a gridview.
Here's my code...
Imports mysql.data.mysqlclient
Imports System.IO
Imports System.Data
Imports System.Windows
Partial Class Default2
Inherits System.Web.UI.Page
Protected Sub startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
'Create the DataTable
Dim dt As New DataTable()
Dim myConnection As New MySqlConnection("server=egr3.egr.nau.edu;uid=wis_str_datt_usr;pwd=xxxxxx;database=wisard_streamed_data_test;")
Dim strSQL As String
'get the data into a datatable
strSQL = "SELECT * FROM streamed_data WHERE ProbeID = 20 AND SensorID = 104"
Dim myAdapter As New MySqlDataAdapter()
myAdapter.SelectCommand = New MySqlCommand(strSQL, myConnection)
myAdapter.Fill(dt)
'test binding to a gridview
'dgdata.DataSource = dt
'dgdata.DataBind()
'lets make a teechart!
Dim Point1 As New Steema.TeeChart.Styles.Points(WebChart1.Chart)
WebChart1.Chart.Axes.Bottom.Labels.DateTimeFormat = "yyyy/MM/dd"
Point1.YValues.DataMember = dt.Columns("measurement").ToString()
Point1.XValues.DateTime = dt.Columns("TimeStamp").DateTimeMode
Point1.DataSource = dt
End Sub
End Class
I'm having a strange problem with date-time data. I'm reading the data from a MySQL database and displaying it as a scatter plot. I can get the x-axis to display as numbers, but when I try to display dates, I get values in the 1900's. The actual data from the database displays properly (recent dates) in a gridview.
Here's my code...
Imports mysql.data.mysqlclient
Imports System.IO
Imports System.Data
Imports System.Windows
Partial Class Default2
Inherits System.Web.UI.Page
Protected Sub startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
'Create the DataTable
Dim dt As New DataTable()
Dim myConnection As New MySqlConnection("server=egr3.egr.nau.edu;uid=wis_str_datt_usr;pwd=xxxxxx;database=wisard_streamed_data_test;")
Dim strSQL As String
'get the data into a datatable
strSQL = "SELECT * FROM streamed_data WHERE ProbeID = 20 AND SensorID = 104"
Dim myAdapter As New MySqlDataAdapter()
myAdapter.SelectCommand = New MySqlCommand(strSQL, myConnection)
myAdapter.Fill(dt)
'test binding to a gridview
'dgdata.DataSource = dt
'dgdata.DataBind()
'lets make a teechart!
Dim Point1 As New Steema.TeeChart.Styles.Points(WebChart1.Chart)
WebChart1.Chart.Axes.Bottom.Labels.DateTimeFormat = "yyyy/MM/dd"
Point1.YValues.DataMember = dt.Columns("measurement").ToString()
Point1.XValues.DateTime = dt.Columns("TimeStamp").DateTimeMode
Point1.DataSource = dt
End Sub
End Class