|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
MySQL采用双重授权(DualLicensed),它们是GPL和MySQLAB制定的商业许可协议。cs页面挪用代码:
复制代码代码以下:
publicintTotalPage=0;
publicintPageCurrent=1;
publicintPageSize=25;
publicintRowsCount=0;
stringuserid,username;
publicDataTabledt=newDataTable();
publicstringpath,userwelcome;
publicstringopt,cid;
protectedvoidPage_Load(objectsender,EventArgse)
{
if(!IsPostBack)
{
if(Request.Params["page"]==nullRequest.Params["page"].ToString().Equals(""))
PageCurrent=1;
else
PageCurrent=int.Parse(Request.Params["page"].ToString());
this.getPage(outTotalPage,outRowsCount,PageSize,PageCurrent);
}
}
//挪用存储历程的函数
privatevoidgetPage(outinttotalPage,outintrowsCount,intpageSize,intcurrentPage)
{
SqlParameter[]parameters={
newSqlParameter("@TotalPage",SqlDbType.Int,4),
newSqlParameter("@RowsCount",SqlDbType.Int,4),
newSqlParameter("@PageSize",SqlDbType.Int,4),
newSqlParameter("@CurrentPage",SqlDbType.Int,4),
newSqlParameter("@SelectFields",SqlDbType.NVarChar,700),
newSqlParameter("@IdField",SqlDbType.NVarChar,50),
newSqlParameter("@OrderField",SqlDbType.NVarChar,200),
newSqlParameter("@OrderType",SqlDbType.NVarChar,2),
newSqlParameter("@TableName",SqlDbType.NVarChar,300),
newSqlParameter("@strWhere",SqlDbType.NVarChar,300),
};
parameters[0].Direction=ParameterDirection.Output;
parameters[1].Direction=ParameterDirection.Output;
parameters[2].Value=pageSize;
parameters[3].Value=currentPage;
parameters[4].Value="a.RLId,a.companyName,a.webSite,a.isRL,a.ordernum,a.isrl,a.userid";
parameters[5].Value="a.RLId";
parameters[6].Value="a.isrlasc,a.orderNum";
parameters[7].Value="1";
parameters[8].Value="qiYeRenlinga";
parameters[9].Value="1=1";//
DataSetds=Wm23Abc.DBUtility.DbHelperSQL.RunProcedure("getRecordByPage",parameters,"dt");
dt=ds.Tables[0];
totalPage=int.Parse(parameters[0].Value.ToString());
rowsCount=int.Parse(parameters[1].Value.ToString());
}
.aspx页面代码:
<tableid="SXFSTable"style="width:100%;"class="table">
<tr><td><b>公司称号</b></td><td><b>公司网址</b></td><td><b>认领形态</b></td></tr>
<%for(inti=0;i<dt.Rows.Count;i++)
{
%>
<tr>
<td><%=dt.Rows["companyName"].ToString()%>排序值:<%=dt.Rows["ordernum"].ToString()%></td>
<td><%=dt.Rows["webSite"].ToString()%>
是不是认领:<%=dt.Rows["userid"].ToString()%></td>
<td><%=dt.Rows["isRL"].ToString().Equals("0")?"<ahref="javascript:;"onclick="renLing(event,"+dt.Rows["RLId"].ToString()+");">认领该企业</a>":"<fontcolor="red">该企业已被认领</font>"%></td>
</tr>
<%
}
%>
</table>
</div>
<divstyle="margin-left:auto;margin-right:auto;width:70%;text-align:left;font-size:9pt;">
第<%=PageCurrent%>页共<%=RowsCount%>条共<%=TotalPage%>页
<%if(PageCurrent!=1)
{
%>
<ahref="test.aspx">首 页</a>
<ahref="test.aspx?page=<%=PageCurrent-1%>">上一页</a>
<%
}
if(PageCurrent!=TotalPage)
{
%>
<ahref="test.aspx?page=<%=PageCurrent+1%>">下一页</a>
<ahref="test.aspx?page=<%=TotalPage%>">末 页</a>
<%
}
%>
</div>
存储历程代码:
复制代码代码以下:
CREATEproc[dbo].[getRecordByPage]
@TotalPageintoutput,--总页数
@RowsCountintoutput,--总条数
@PageSizeint,--每页几数据
@CurrentPageint,--以后页数
@SelectFieldsnvarchar(1000),--select语句可是不包括select
@IdFieldnvarchar(50),--主键列
@OrderFieldnvarchar(50),--排序字段,假如是多个字段,除最初一个字段外,前面都要加排序前提(asc/desc),不包括orderby,最初一个排序字段不必加排序前提
@OrderTypenvarchar(4),--1升序,0降序
@TableNamenvarchar(200),--表名
@strWherenvarchar(300)--前提
As
Begin
declare@RecordCountfloat
declare@PageNumint--分页根据数
Declare@Comparenvarchar(50)--对照字段辨别min大概max
Declare@Compare1nvarchar(2)--年夜于号“>”大概小于号"<“
Declare@OrderSqlnvarchar(10)--排序字段
declare@Sqlnvarchar(4000)
Declare@TemSqlnvarchar(1000)
Declare@nRdint
declare@afterRowsint
declare@tempTableNamenvarchar(10)
if(@OrderType=1)
Begin
set@OrderSql=asc
End
Else
Begin
set@OrderSql=desc
End
if(isnull(@strWhere,))
Set@strWhere=@strWhere
if(@strWhere=)
Set@strWhere=1=1
Set@TemSql=Select@RecordCount=Count(1)from+@TableName+where+@strWhere
execsp_executesql@TemSql,N@RecordCountfloatoutput,@RecordCountoutput
Set@RowsCount=@RecordCount
Set@TotalPage=ceiling(@RecordCount/@PageSize)
if(@CurrentPage>@TotalPage)
Set@CurrentPage=@TotalPage
if(@CurrentPage<1)
Set@CurrentPage=1
if(@PageSize<1)
Set@PageSize=1
print(@RecordCount)
if(@CurrentPage=1)
Begin
setRowcount@PageSize
set@Sql=select+@SelectFields+from+@TableName+where+@strWhere+orderby+@OrderField+
+@OrderSql+,+@IdField+asc
--print(@Sql)
execsp_executeSql@Sql
End
elseif(@CurrentPage=@TotalPage)
begin
set@afterRows=@RowsCount-(@CurrentPage-1)*@PageSize
setRowCount@afterRows
if(@OrderType=1)
begin
set@OrderField=REPLACE(@OrderField,asc,lai512343975)//这里用变量将asc和desc交换,哈哈,太神了
set@OrderField=REPLACE(@OrderField,desc,asc)
set@OrderField=REPLACE(@OrderField,lai512343975,desc)
set@Sql=select+@SelectFields+from+@TableName+where+@strWhere+orderby+@OrderField+desc+,+@IdField+asc
end
else
begin
set@OrderField=REPLACE(@OrderField,desc,lai512343975)
set@OrderField=REPLACE(@OrderField,asc,desc)
set@OrderField=REPLACE(@OrderField,lai512343975,asc)
set@Sql=select+@SelectFields+from+@TableName+where+@strWhere+orderby+@OrderField+asc+,+@IdField+asc
print(@Sql)
end
--print(@Sql)
execsp_executeSql@Sql
end
else
Begin
set@nRd=@PageSize*(@CurrentPage-1)
print(@nRd)
setRowCount@PageSize
set@Sql=select+@SelectFields+from+@TableName+where+@strWhere+and+@IdField+notin(selecttop+cast(@nRdasnvarchar(10))++@IdField+from+@TableName+where+@strWhere+orderby+@OrderField++@OrderSql+,+@IdField+asc)+orderby+@OrderField++@OrderSql+,+@IdField+asc
execsp_executeSql@Sql
--Print(@sql)
End
end
GO
无疑希望员工得到系统、有深度的培训,显然MySQL在这一点上还做得很不够。 |
|