Candle Serie + DBNull in dataset
Posted: Wed Jan 04, 2006 5:43 pm
Hello,
When I associate a Candle serie to a dataset with NULL rows (See example below) then I receive the error "Object cannot be cast from DBNull to other types".
Can you tel me How to manage that.
Thanks in advance.
Sample code:
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim DataSet_Obj As New DataSet
Dim DataRow_Obj As DataRow
Dim Tag_Serie_Candle As Steema.TeeChart.Styles.Candle
DataSet_Obj.Tables.Add("CandleTable")
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("Date", System.Type.GetType("System.DateTime")))
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("Open", System.Type.GetType("System.Double")))
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("Close", System.Type.GetType("System.Double")))
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("High", System.Type.GetType("System.Double")))
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("Low", System.Type.GetType("System.Double")))
DataRow_Obj = DataSet_Obj.Tables("CandleTable").NewRow()
DataRow_Obj("Date") = CDate("01/01/2005 10:00:00")
DataRow_Obj("Low") = 100
DataRow_Obj("Close") = 110
DataRow_Obj("Open") = 120
DataRow_Obj("High") = 130
DataSet_Obj.Tables("CandleTable").Rows.Add(DataRow_Obj)
DataRow_Obj = Nothing
DataRow_Obj = DataSet_Obj.Tables("CandleTable").NewRow()
DataRow_Obj("Date") = CDate("01/01/2005 10:10:00")
' SIMULATE NULL VALUES
DataSet_Obj.Tables("CandleTable").Rows.Add(DataRow_Obj)
DataRow_Obj = Nothing
DataRow_Obj = DataSet_Obj.Tables("CandleTable").NewRow()
DataRow_Obj("Date") = CDate("01/01/2005 10:20:00")
DataRow_Obj("Low") = 120
DataRow_Obj("Close") = 130
DataRow_Obj("Open") = 140
DataRow_Obj("High") = 150
DataSet_Obj.Tables("CandleTable").Rows.Add(DataRow_Obj)
DataRow_Obj = Nothing
Tag_Serie_Candle = New Steema.TeeChart.Styles.Candle
TChart1.Series.Add(Tag_Serie_Candle)
Tag_Serie_Candle.DataSource = DataSet_Obj.Tables("CandleTable")
Tag_Serie_Candle.OpenValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("Open").ToString()
Tag_Serie_Candle.CloseValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("Close").ToString()
Tag_Serie_Candle.DateValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("Date").ToString()
Tag_Serie_Candle.DateValues.DateTime = True
Tag_Serie_Candle.HighValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("High").ToString()
Tag_Serie_Candle.LowValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("Low").ToString()
Tag_Serie_Candle.LabelMember = "Test ACTL"
Tag_Serie_Candle.CheckDataSource()
When I associate a Candle serie to a dataset with NULL rows (See example below) then I receive the error "Object cannot be cast from DBNull to other types".
Can you tel me How to manage that.
Thanks in advance.
Sample code:
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim DataSet_Obj As New DataSet
Dim DataRow_Obj As DataRow
Dim Tag_Serie_Candle As Steema.TeeChart.Styles.Candle
DataSet_Obj.Tables.Add("CandleTable")
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("Date", System.Type.GetType("System.DateTime")))
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("Open", System.Type.GetType("System.Double")))
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("Close", System.Type.GetType("System.Double")))
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("High", System.Type.GetType("System.Double")))
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("Low", System.Type.GetType("System.Double")))
DataRow_Obj = DataSet_Obj.Tables("CandleTable").NewRow()
DataRow_Obj("Date") = CDate("01/01/2005 10:00:00")
DataRow_Obj("Low") = 100
DataRow_Obj("Close") = 110
DataRow_Obj("Open") = 120
DataRow_Obj("High") = 130
DataSet_Obj.Tables("CandleTable").Rows.Add(DataRow_Obj)
DataRow_Obj = Nothing
DataRow_Obj = DataSet_Obj.Tables("CandleTable").NewRow()
DataRow_Obj("Date") = CDate("01/01/2005 10:10:00")
' SIMULATE NULL VALUES
DataSet_Obj.Tables("CandleTable").Rows.Add(DataRow_Obj)
DataRow_Obj = Nothing
DataRow_Obj = DataSet_Obj.Tables("CandleTable").NewRow()
DataRow_Obj("Date") = CDate("01/01/2005 10:20:00")
DataRow_Obj("Low") = 120
DataRow_Obj("Close") = 130
DataRow_Obj("Open") = 140
DataRow_Obj("High") = 150
DataSet_Obj.Tables("CandleTable").Rows.Add(DataRow_Obj)
DataRow_Obj = Nothing
Tag_Serie_Candle = New Steema.TeeChart.Styles.Candle
TChart1.Series.Add(Tag_Serie_Candle)
Tag_Serie_Candle.DataSource = DataSet_Obj.Tables("CandleTable")
Tag_Serie_Candle.OpenValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("Open").ToString()
Tag_Serie_Candle.CloseValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("Close").ToString()
Tag_Serie_Candle.DateValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("Date").ToString()
Tag_Serie_Candle.DateValues.DateTime = True
Tag_Serie_Candle.HighValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("High").ToString()
Tag_Serie_Candle.LowValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("Low").ToString()
Tag_Serie_Candle.LabelMember = "Test ACTL"
Tag_Serie_Candle.CheckDataSource()