请教一下大家!
我在asp.net中有这样一段!
................
SqlDataReader thisReader1 = sqlSelectCommand2.ExecuteReader();
string sc,total;
while(thisReader1.Read())
{
sc=(string)thisReader1["ysc"];
}
上面没有问题,但如果加上一句,就不对了,如下!
................
SqlDataReader thisReader1 = sqlSelectCommand2.ExecuteReader();
string sc,total;
while(thisReader1.Read())
{
sc=(string)thisReader1["ysc"];
total=thisReader1.GetInt32(0).ToString;
}
后加的该字段类型为整数型!
编译时,会提示:
Exception Details: System.InvalidCastException: Specified cast is not valid.
请问怎么解决?