本帖最后由 yanxinjia 于 2011-02-18 17:16:02 编辑

解决方案 »

  1.   

    异常消息为:用户代码未处理 System.NullReferenceException  Message="未将对象引用设置到对象的实例。"
      Source="WebApplication1"
      StackTrace:
           在 WebApplication1.DBHelp.ExcuteDataSet(String sql, CommandType type, SqlParameter[] parms) 位置 D:\DataProc\WebApplication1\WebApplication1\DBProc.cs:行号 147
           在 WebApplication1.Default.Page_Load(Object sender, EventArgs e) 位置 D:\DataProc\WebApplication1\WebApplication1\Default.aspx.cs:行号 75
           在 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
           在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
           在 System.Web.UI.Control.OnLoad(EventArgs e)
           在 System.Web.UI.Control.LoadRecursive()
           在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      InnerException: 
      

  2.   

    Response.Write("<script>window.alert('" + "GetMaxTZYM" + "')</script>");  是不是用了updatepanel
      

  3.   

    ds.Tables[0].  空引用看看你得sql 查处数据来没
      

  4.   

    你调用这个方法了吗public int GetMaxTZYM()在哪调的?
      

  5.   

    Response.Write("<script>alert('GetMaxTZYM');</script>");  
    如果没使用UpdatePanel的话是可行的。异常信息是:
    DataSet ds = DBHelp.ExcuteDataSet(sql, CommandType.Text, null);
    返回的ds为null
      

  6.   

    string sql = "select max(tzyy*100+tzmm) tzym from dwtz";
      DataSet ds = DBHelp.ExcuteDataSet(sql, CommandType.Text, null);
    if(ds!=null &&ds.Tables[0]!=null && ds.Tables[0].Rows.Count > 0)
      {
      i = int.Parse(ds.Tables[0].Rows[0]["tzym"].ToString());
      }
      

  7.   

    ds 对象的没有得到, 导致ds对象为空, 就出错了
      

  8.   

    如果空不是你预期的结果那么就要好的检查 DBHelp.ExcuteDataSet(sql, CommandType.Text, null)这句它确保它不是null
    反之应处理空的值如上面提到的
    if(ds!=null &&ds.Tables[0]!=null && ds.Tables[0].Rows.Count > 0)
      {
      i = int.Parse(ds.Tables[0].Rows[0]["tzym"].ToString());
      }
      

  9.   


    DataSet ds = DBHelp.ExcuteDataSet(sql, CommandType.Text, null);
    这里加上
    if(ds!=null){  if (ds.Tables[0].Rows.Count > 0)
      {
      i = int.Parse(ds.Tables[0].Rows[0]["tzym"].ToString());
      }
    }  return i;