日期:2014-05-19  浏览次数:20744 次

关于一个cast的问题
代码片段如下:
double[,]   sale   =   new   double[dt1.Rows.Count,1];
OleDbCommand   com5   =   new   OleDbCommand( "SELECT   Sale   FROM   E_Store ",   conn);
OleDbDataReader   dr2   =   com5.ExecuteReader();
while(dr2.Read())
{
sale[dr2.Depth,0]   =   (double)dr2.GetValue(0);
}
dr2.Close();

问题出在cast那行。。。。。。

sale的数据全是double的值

请问问题在那?、

谢谢


------解决方案--------------------
Convert.ToDouble(dr2.GetValue(0));
------解决方案--------------------
double[,] sale = new double[dt1.Rows.Count,1];
OleDbCommand com5 = new OleDbCommand( "SELECT Sale FROM E_Store ", conn);
OleDbDataReader dr2 = com5.ExecuteReader();
while(dr2.Read())
{
sale[dr2.Depth,0] = dr2.GetDouble(0);
}
dr2.Close();