public SqlParameter[] DealwithCrimeCount=new SqlParameter[28];
 public void GetDealwithCrimCount(DateTime timeStart, DateTime timeEnd)
    {
        {
            DealwithCrimeCount[0] = new SqlParameter("@DealwithCrimeCount1",SqlDbType.Int,4);
            DealwithCrimeCount[1] = new SqlParameter("@DealwithCrimeCount2", SqlDbType.Int, 4);
            DealwithCrimeCount[2] = new SqlParameter("@DealwithCrimeCount3", SqlDbType.Int, 4);
       };
        DealwithCrimeCount[0].Direction = ParameterDirection.Output;   //为存储过程的输出参数        DealwithCrimeCount[1].Direction = ParameterDirection.Output;
        DealwithCrimeCount[2].Direction = ParameterDirection.Output;        DataSet ds = this.dbProcessor.RunProcedure("Cup_Work_GetDealwithCrimecount", DealwithCrimeCount, "GetDealwithCrimeCount");
        DataTable dt = ds.Tables["GetDealwithCrimeCount"];}DataTable dt = new DataTable();
        dt1.Columns.Add(new DataColumn("核对方法",typeof(string)));
        dt1.Columns.Add(new DataColumn("上月未结",typeof(int)));
        dt1.Columns.Add(new DataColumn("小计",typeof(int))); 
 
        dt1.Rows.Add(new object[] { "合计", GetAll(), 0, GetArrestcount(), -1,  0, 0, 0, 0, 0 });
        dt1.Rows.Add(new object[] { "逮捕", GetAllArrest(), 0, 0, -1, -1,  0, 0, 0, 0, 0 });
        dt1.Rows.Add(new object[] { "刑事拘留", GetAllCustoy(), 0, Convert.ToInt32(DealwithCrimeCount[2].Value), -1, -1});
        dt1.Rows.Add(new object[] { "取保候审", GetAllBail(), 0, Convert.ToInt32(DealwithCrimeCount[3].Value), -1, });
        dt1.Rows.Add(new object[] { "监视居住", GetAllScountHouse(), 0, Convert.ToInt32(DealwithCrimeCount[4].Value), 
出现未将对象引用设置到对象的实例。什么原因啊??望指教~~

解决方案 »

  1.   

    DealwithCrimeCount数组没有填充啊
      

  2.   

    你确定DealwithCrimeCount的[2][3][4]这三个都是输出参数吗???
      

  3.   

    DealwithCrimeCount虽然声明了,但没有实例化,还有你的 GetDealwithCrimCount 是在哪里调用的?
      

  4.   

    public SqlParameter[] DealwithCrimeCount=new SqlParameter[28]; 整个数组的数据我都要用的啊?数组的元素我都是从存储过程的输出参数获得的啊??
     DataSet ds = this.dbProcessor.RunProcedure("Cup_Work_GetDealwithCrimecount", DealwithCrimeCount, "GetDealwithCrimeCount"); 
     DataTable dt = ds.Tables["GetDealwithCrimeCount"]; 
      

  5.   

    你的存储过程输出没有把数据带回来,所以你的数组没有数据。检查存储过程;存储过程中返回多个值不能用return,直接定义成output然后赋值就可以了。要不你先不要返回给数组,先返回给一个变量,然后把它显示出来看有没有返回值。调试下就知道问题了。
      

  6.   

    存储过程已经将数据带出来了,现在的错误是Convert.ToInt32(DealwithCrimeCount[2].Value)等未将对象引用设置到对象的实例??
      

  7.   

    DealwithCrimeCount[2].Value  这个没有创建吧!
      

  8.   

    不是public SqlParameter[] DealwithCrimeCount=new SqlParameter[28]; 在里面了啊,存储过程输出的参数全放在里面了啊~~我现在用用数组里的值,难道这样DealwithCrimeCount[2].Value 写不行??