对象不能从 DBNull 转换为其他类型。 在线等
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------
对象不能从 DBNull 转换为其他类型。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.InvalidCastException: 对象不能从 DBNull 转换为其他类型。
源错误:
行 24: else
行 25: {
行 26: if (Convert.ToInt32(obj) > 0)
行 27: {
行 28: result = obj.ToString();
代码:
public string Getjingsuchengdui(string name, int yue)
{
string result = "";
string str = " select CAST (SUM(Money) as decimal) from SCM_TransFunds,SCM_TransFunds4 where SCM_TransFunds.BillID=SCM_TransFunds4.BillID and DealerID=(select ID from CP_DLR where [name]='" + name + "') and jiesuanleixing=1 and BillDate>dateadd(mm," + -yue + ",getdate()) ";
object obj = SqlHelper.ExecuteScalar(SqlHelper.jiangsu, CommandType.Text, str);
if (obj == null)
{
return "0";
}
else
{
if (Convert.ToInt32(obj) > 0)
{
result = obj.ToString();
}
return result;
}
}
可以在线回答也可以加我qq99265117