★★有关Sql 2000与asp.net的数据格式问题★★
我在数据库中有一个double类型的项,但是它是以.8978等的形式存在的,
DataTable table = new DataTable();
DataColumn month = new DataColumn();
month.DataType = System.Type.GetType("System.String");
month.ColumnName="month";
table.Columns.Add(month);
DataColumn charge = new DataColumn();
charge.DataType = System.Type.GetType("System.Double");
charge.ColumnName="charge";
table.Columns.Add(charge);
DataColumn scale = new DataColumn();
scale.DataType = System.Type.GetType("System.String");
scale.ColumnName="scale";
table.Columns.Add(scale);
当我把数据读入table的"charge"列时候,
table.Rows[index]["charge"]= newDataReader[0];
double current = Convert.ToDouble( table.Rows[index]["charge"].ToString() );
报告:
System.FormatException: 输入字符串的格式不正确。
源错误:
行 71: table.Rows[index]["month"]=i.ToString()+"月";
行 72: table.Rows[index]["charge"]= newDataReader[0];
行 73: double current = Convert.ToDouble( table.Rows[index]["charge"].ToString() );
行 74: double last = Convert.ToDouble( table.Rows[index-1]["charge"].ToString() );
这是为什么???
请教高手?
行 75: if(index!=0 && last!=0)