存储过程的位置:
http://www.cnblogs.com/hertcloud/archive/2005/12/21/301327.html我的代码:
SqlConnection cnn=new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand _comm = new SqlCommand("proc_ListPageInt",cnn);
_comm.CommandType = CommandType.StoredProcedure;
SqlDataReader dr=null;
_comm.Parameters.Add("@tblName", SqlDbType.NVarChar, 200);
_comm.Parameters["@tblName"].Value = " info_public ";
_comm.Parameters.Add("@fldName", SqlDbType.NVarChar, 500);
_comm.Parameters["@fldName"].Value = " * ";
_comm.Parameters.Add("@pageSize", SqlDbType.Int);
_comm.Parameters["@pageSize"].Value = 5;
_comm.Parameters.Add("@page", SqlDbType.Int);
_comm.Parameters["@page"].Value = 1;
_comm.Parameters.Add("@fldSort", SqlDbType.NVarChar, 200);
_comm.Parameters["@fldSort"].Value = " infoid ";
_comm.Parameters.Add("@Sort", SqlDbType.Bit);
_comm.Parameters["@Sort"].Value = true;
_comm.Parameters.Add("@strCondition", SqlDbType.NVarChar, 1000);
_comm.Parameters["@strCondition"].Value =" ";
_comm.Parameters.Add("@ID", SqlDbType.NVarChar, 150);
_comm.Parameters["@ID"].Value = " infoid ";
_comm.Parameters.Add("@Counts", SqlDbType.Int, 0);
_comm.Parameters["@Counts"].Direction = ParameterDirection.Output;
_comm.Parameters.Add("@pageCount", SqlDbType.Int, 0);
_comm.Parameters["@pageCount"].Direction = ParameterDirection.Output;
cnn.Open();
dr=_comm.ExecuteReader();
//dr.Read();//有没有都一样去不到值!
string gdds="ff";
gdds=(string)_comm.Parameters["@Counts"].Value;
Response.Write(gdds);//网页上没有任何东西输出!dr 有值,而out int counts,out int pageCounts 取不到值 就80分了,全部给了!~
http://www.cnblogs.com/hertcloud/archive/2005/12/21/301327.html我的代码:
SqlConnection cnn=new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand _comm = new SqlCommand("proc_ListPageInt",cnn);
_comm.CommandType = CommandType.StoredProcedure;
SqlDataReader dr=null;
_comm.Parameters.Add("@tblName", SqlDbType.NVarChar, 200);
_comm.Parameters["@tblName"].Value = " info_public ";
_comm.Parameters.Add("@fldName", SqlDbType.NVarChar, 500);
_comm.Parameters["@fldName"].Value = " * ";
_comm.Parameters.Add("@pageSize", SqlDbType.Int);
_comm.Parameters["@pageSize"].Value = 5;
_comm.Parameters.Add("@page", SqlDbType.Int);
_comm.Parameters["@page"].Value = 1;
_comm.Parameters.Add("@fldSort", SqlDbType.NVarChar, 200);
_comm.Parameters["@fldSort"].Value = " infoid ";
_comm.Parameters.Add("@Sort", SqlDbType.Bit);
_comm.Parameters["@Sort"].Value = true;
_comm.Parameters.Add("@strCondition", SqlDbType.NVarChar, 1000);
_comm.Parameters["@strCondition"].Value =" ";
_comm.Parameters.Add("@ID", SqlDbType.NVarChar, 150);
_comm.Parameters["@ID"].Value = " infoid ";
_comm.Parameters.Add("@Counts", SqlDbType.Int, 0);
_comm.Parameters["@Counts"].Direction = ParameterDirection.Output;
_comm.Parameters.Add("@pageCount", SqlDbType.Int, 0);
_comm.Parameters["@pageCount"].Direction = ParameterDirection.Output;
cnn.Open();
dr=_comm.ExecuteReader();
//dr.Read();//有没有都一样去不到值!
string gdds="ff";
gdds=(string)_comm.Parameters["@Counts"].Value;
Response.Write(gdds);//网页上没有任何东西输出!dr 有值,而out int counts,out int pageCounts 取不到值 就80分了,全部给了!~
http://community.csdn.net/Expert/topic/5269/5269439.xml?temp=.632168
declare @P1 int
set @P1=19
declare @P2 int
set @P2=4
exec proc_ListPageInt @tblName = N' info_public ', @fldName = N' * ', @pageSize = 5, @page = 1, @fldSort = N' infoid ', @Sort = 1, @strCondition = N' ', @ID = N' infoid ', @Counts = @P1 output, @pageCount = @P2 output
select @P1, @P2------------------------------------------
结果:
表1:
ID Title ...
----------------------------------------
1 kkkkkkk ....
..
.. 表2:
无名列 无名列
------------------------------------
19 4”无名列“就是输出参数的值!
在这个dataset里有两个表 一个是你要输出的参数值
一个是查询的记录 可以根据需要返回 好多表
比如:存储过程里有语句:
select 'aaa'
select 'bbb'
dataset里有两个表 分别存放了 记录'aaa' 和'bbb'