Column Expression Bug in VS.NET 2003

M

mikeorb

I could not find this bug mentioned in the MSDN KB and only found one
mention in USENET after lots of searching:

http://tinyurl.com/ckvt4

I could not get aggregate child column expressions to work when they
were defined in a DataSet using the DataSet designer. For example, I
added a new column named max_score with an expression of
Max(Child.score). When I tried to access a cell via the typed DataSet I
received an error:

System.InvalidCastException: Specified cast is not valid.

Expressions that did not use relations seemed to work OK.

The fix is to define the expression again (or for the 1st time
manually) after the DataSet's individual tables have been loaded (or
perhaps after the relation has been defined). For example:

Data_Set.places.Columns["max_score"].Expression =
Data_Set.places.Columns["max_score"].Expression;

This bug should be more widely documented. And why was there never a
service pack for VS.NET 2003? Surely many bugs could have been fixed
like this before VS.NET 2005.

This is an error in the VS.NET designer. If you can't tell already, I'm
really annoyed that it was never fixed.

-Mike
 
M

mikeorb

And here is some trivial code to reset expressions, since I still like
using the DataSet designer:

foreach (DataTable table in Data_Set.Tables)
{
foreach (DataColumn col in table.Columns)
{
col.Expression = col.Expression;
}
}

-Mike
 
M

mikeorb

Maybe not so trivial I guess. Need to only set Expression when not
empty (I swear it worked the first time!):

foreach (DataTable table in Data_Set.Tables)
{
foreach (DataColumn col in table.Columns)
{
if (col.Expression != "")
col.Expression = col.Expression;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top