应用该存储过程

private DataSet GetPageData(uint pageSize, uint pageIndex)     
  {          
   string strConn = System.Configuration.ConfigurationSettings.AppSettings["ConnString1"];                    
   SqlConnection conn = new SqlConnection(strConn);          
   conn.Open();           
   SqlCommand command = new SqlCommand("GetCustomDataPage",conn);
   //第一个参数为存储过程名         
   command.CommandType = CommandType.StoredProcedure;  
   //声明命令类型为存储过程          
   command.Parameters.Add("@pageSize",SqlDbType.Int);         
   command.Parameters["@pageSize"].Value = pageSize;         
   command.Parameters.Add("@pageIndex",SqlDbType.Int);          
   command.Parameters["@pageIndex"].Value = pageIndex;          
   command.Parameters.Add("@pageCount",SqlDbType.Int);          
   command.Parameters["@pageCount"].Value = pageCount;           
   command.Parameters["@pageCount"].Direction = ParameterDirection.Output;
   //存储过程中的输出参数           
   command.Parameters.Add("@recordCount",SqlDbType.Int);          
   command.Parameters["@recordCount"].Value = recordCount;           
   command.Parameters["@recordCount"].Direction = ParameterDirection.Output;
   //存储过程中的输出参数            
   SqlDataAdapter adapter = new SqlDataAdapter(command);         
   DataSet ds = new DataSet();          
   adapter.Fill(ds);                     
   //获得输出参数值         
   pageCount = Convert.ToUInt32(command.Parameters["@pageCount"].Value);      
   recordCount = Convert.ToUInt32(command.Parameters["@recordCount"].Value);     
   conn.Close();         
   return ds;        
  }       

//绑定数据到DataGrid中      
  private void BindDataGrid()     
  {        
   DataSet ds = GetPageData((uint)dgProduct.PageSize,(uint)dgProduct.CurrentPageIndex); 
   dgProduct.VirtualItemCount = (int)recordCount;           
   dgProduct.DataSource = ds;         
   dgProduct.DataBind();     
  }       

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

应用该存储过程

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭