读书人

很简单的代码报出的错误看来小弟我有

发布时间: 2012-01-28 22:06:13 作者: rapoo

很简单的代码报出的异常,看来我有点晕了。
如下很简单的代码报出了一个异常:
DataSet ds = new DataSet( "FirstDataSet ");
//ds.Tables.Add( "dt ");
DataTable dt = new DataTable( "table1 ");
DataColumn price = new DataColumn( "column1 ", typeof(System.Int32));
DataColumn count = new DataColumn( "column2 ", typeof(System.Int32));
dt.Columns.Add(price);
dt.Columns.Add(count);

DataColumn agg = new DataColumn( "column3 ", typeof(System.Int32));
agg.Expression = "count*price ";
dt.Columns.Add(agg); // 在此报出了异常:Cannot find column [count].

请问:为什么会报出异常?如何调试?

[解决办法]

读书人网 >.NET Framework

热点推荐