DateTime XValues DB Column

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Sonia
Newbie
Newbie
Posts: 4
Joined: Tue Oct 26, 2004 4:00 am

DateTime XValues DB Column

Post by Sonia » Tue Nov 09, 2004 10:13 pm

Hi.
I Use database table as line series datasouce.
In this table exists Date Column(X) and Value Column(Y).
When the Value is DBNull I get error:"Object cannot be cast from DBNull to other types".
If I change X and Y to Value Column DataMember it don't happens.
What is the trouble with dateTime Column?

Steema.TeeChart.Styles.Line serLine = new Steema.TeeChart.Styles.Line();
tcrBase.Series.Add(serLine);
serLine.DataSource = dt;
serLine.XValues.DataMember=DateColumnName;
serLine.YValues.DataMember = valueColumnName;

Thanks,Sonia

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Nov 10, 2004 3:25 pm

Hi Sonia,

I've just test it here using the following code (with the latest available version) and does not give me any error. But I've noticed that it does not work as it should, the problem is that instead of one null value at the beginning of the series and one at the end there are two at the beginning. I've added this on our defect list and a fix for it will be considered to inclusion for the next emaintenance releases.

Code: Select all

Random r=new Random(10);

DataTable myTable = new DataTable("myTable"); 
DataColumn colDate = new DataColumn("Date",Type.GetType("System.DateTime"));
DataColumn colValue = new DataColumn("Value",Type.GetType("System.Int32"));

myTable.Columns.Add(colDate);
myTable.Columns.Add(colValue);

// Add five items.
DataRow NewRow;

NewRow = myTable.NewRow();
NewRow["Date"] = DBNull.Value;
NewRow["Value"] = DBNull.Value;
myTable.Rows.Add(NewRow);

for(int i = 0; i <5; i++)
{
NewRow = myTable.NewRow();
NewRow["Date"] = System.DateTime.Today.AddDays(i);
NewRow["Value"] = r.Next(10);
myTable.Rows.Add(NewRow);
}

NewRow = myTable.NewRow();
NewRow["Date"] = System.DateTime.Today.AddDays(7);
NewRow["Value"] = DBNull.Value;
myTable.Rows.Add(NewRow);


DataView firstView = new DataView(myTable);

tChart1.Series[0].YValues.DataMember=colValue.ToString();
tChart1.Series[0].XValues.DateTime = true;
tChart1.Series[0].XValues.DataMember=colDate.ToString();
tChart1.Series[0].DataSource=firstView;

Post Reply