public static double AvgFromDB(int id, DateTime time, int userID)
{
DateTime startTime = DateTime.Parse( time.Year.ToString() + "-" + time.Month.ToString() + "-01 00:00:00");
string sqlString = "select average from HourAssessmentMonthScore where ownerId ='" + id + "'and workgroup = '" + userID + "' and date = '" + startTime + "'";
string returnValue = runSQL(sqlString);
if (returnValue == null || returnValue.Length==0)
//throw new Exception("error no data!");
return Convert.ToDouble(0);
else
return Convert.ToDouble(returnValue);
}这段代码怎么改始终报object reference not set to an instance of an boject。由于某些原因暂时无法调试,请高手帮忙看看问题到底出在哪。谢谢,在线等。
{
DateTime startTime = DateTime.Parse( time.Year.ToString() + "-" + time.Month.ToString() + "-01 00:00:00");
string sqlString = "select average from HourAssessmentMonthScore where ownerId ='" + id + "'and workgroup = '" + userID + "' and date = '" + startTime + "'";
string returnValue = runSQL(sqlString);
if (returnValue == null || returnValue.Length==0)
//throw new Exception("error no data!");
return Convert.ToDouble(0);
else
return Convert.ToDouble(returnValue);
}这段代码怎么改始终报object reference not set to an instance of an boject。由于某些原因暂时无法调试,请高手帮忙看看问题到底出在哪。谢谢,在线等。
{
using (SqlConnection Conn = ReturnConn())
{
SqlCommand dbCommand = new SqlCommand(sQueryString, Conn);
string s = dbCommand.ExecuteScalar().ToString();
Conn.Close();
return s;
}
}runsql的方法。因为某些方法不能让我去调试。否则我也不用这么纠结了。
if(objValue==null)return string.Empty;
return objValue.ToString();