我用数据生成工具生成了DataGridView
添加查询时用到了一个存储过程
现在调用这个方法时
this.studentinfoTableAdapter.FillByPage(this.custDataSet.studentinfo,"studentinfo","custid",0,false,"*",25,this.cmbPage.SelectedIndex + 1,"",pages);
其中pages  是 output类型的,我不知道在这里调用时怎么写,请教各位

解决方案 »

  1.   

    在DataSet的设计界面,FillByPage的Parameters属性里面,把pages的方向设为Output
      

  2.   

    我改了
    那怎么定义pages数据类型呀,
    是不是  int pages;
      

  3.   

    int pages;this.studentinfoTableAdapter.FillByPage(this.custDataSet.studentinfo,"studentinfo","custid",0,false,"*",25,this.cmbPage.SelectedIndex + 1,"", out pages);
      

  4.   

    呃,不一定对,我没用过Command对象带Output参数的TableAdapter具体参看TableAdapter自己生成的FillByPages的参数列表如果最后一个是“out int pages”那就是上面的写法
      

  5.   

    我试了  这么写是错误的
    最后一个是  out int?
      

  6.   

    我特意去测试了一下如果TableAdapter某个方法调用的Command对象包含Direction=Output的Parameter的话,它自动生成的方法定义里面也就会有一个out的参数out参数在定义的时候,是 out <类型> <参数名>,
    调用的时候,是 out <变量名>但是你现在就根本不是在定义,是在调用,所以写“out int”是完全没有道理的如果你的pages参数不是int型的,在定义的时候就要改成相应的型,例如如果是long型的,就:long pages;
    <tableAdapterObject>.FillByXXX(...................., out pages);
      

  7.   

    还是有错误呀,我是这么调用的
    int pages;
    this.studentinfoTableAdapter.FillByPage(this.custDataSet.studentinfo, "studentinfo", "custid", 0, false, "*", 25, 10, "",out pages);  错误是
    参数“10”: 无法从“out int”转换为“out int?”
      

  8.   

    哦,那是因为你的参数是nullable了(可为空)那就写“int? pages;”返回之后要判断有没有值:if (pages.HasValue)
      textBox1.Text = "页数: " + pages.Value;