ASP.NET结合存储过程写的通用搜索分页程序

asp.net|程序|存储过程|分页

存储过程改自bigeagle的论坛分页程序。请大家批判!:)
select.aspx
--------------------------------------------------------------------------------

<%@ Page Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

protected void Page_Load(Object sender, EventArgs e)
{
int intPageNo,intPageSize,intPageCount;
intPageSize = 25;
if (Request["CurrentPage"]==null)
{
intPageNo = 1;
}
else
{
intPageNo = Int32.Parse(Request["CurrentPage"]);
}

SqlConnection mySqlConnection = new SqlConnection("server=(local);Database=test;user id=sa;password=");
SqlCommand mySqlCommand = new SqlCommand("up_GetTopicList", mySqlConnection);
mySqlCommand.CommandType = CommandType.StoredProcedure;

SqlParameter workParm;

//搜索表字段,以","号分隔
workParm = mySqlCommand.Parameters.Add("@a_TableList", SqlDbType.VarChar, 200);
mySqlCommand.Parameters["@a_TableList"].Value = "OFFERID,type,offertime";

//搜索表名
workParm = mySqlCommand.Parameters.Add("@a_TableName", SqlDbType.VarChar, 30);
mySqlCommand.Parameters["@a_TableName"].Value = "offer";

//搜索条件,如"select * from aa where a=1 and b=2 and c=3"则条件为"where a=1 and b=2 and c=3"
workParm = mySqlCommand.Parameters.Add("@a_SelectWhere", SqlDbType.VarChar, 500);
mySqlCommand.Parameters["@a_SelectWhere"].Value = "where type='idl'";

//表主键字段名,必须为INT类型
workParm = mySqlCommand.Parameters.Add("@a_SelectOrderId", SqlDbType.VarChar, 50);
mySqlCommand.Parameters["@a_SelectOrderId"].Value = "offerid";

//排序,可以使用多字段排序但主键字段必需在最前面
workParm = mySqlCommand.Parameters.Add("@a_SelectOrder", SqlDbType.VarChar, 50);
mySqlCommand.Parameters["@a_SelectOrder"].Value = "order by offerid desc";

//页号
workParm = mySqlCommand.Parameters.Add("@a_intPageNo", SqlDbType.Int);
mySqlCommand.Parameters["@a_intPageNo"].Value = intPageNo;

//每页显示数
workParm = mySqlCommand.Parameters.Add("@a_intPageSize", SqlDbType.Int);
mySqlCommand.Parameters["@a_intPageSize"].Value = intPageSize;

//总记录数(存储过程输出参数)
workParm = mySqlCommand.Parameters.Add("@RecordCount", SqlDbType.Int);
workParm.Direction = ParameterDirection.Output;

//当前页记录数(存储过程返回值)
workParm = mySqlCommand.Parameters.Add("RowCount", SqlDbType.Int);
workParm.Direction = ParameterDirection.ReturnValue;

mySqlConnection.Open();
Repeater.DataSource = mySqlCommand.ExecuteReader();

Repeater.DataBind();

mySqlConnection.Close();

Int32 RecordCount = (Int32)mySqlCommand.Parameters["@RecordCount"].Value;
Int32 RowCount = (Int32)mySqlCommand.Parameters["RowCount"].Value;

LabelRecord.Text = RecordCount.ToString();
LabelRow.Text = intPageNo.ToString();
intPageCount = RecordCount/intPageSize;
if ((RecordCount%intPageSize)>0)
intPageCount += 1;
LabelPage.Text = intPageCount.ToString();

if (intPageNo>1)
{
HLFistPage.NavigateUrl = "select.aspx?CurrentPage=1";
HLPrevPage.NavigateUrl = String.Concat("select.aspx?CurrentPage=","",intPageNo-1);
}
else
{
HLFistPage.NavigateUrl = "";
HLPrevPage.NavigateUrl = "";
//HLFistPage.Enabled = false;
//HLPrevPage.Enabled = false;
}

if (intPageNo<intPageCount)
{
HLNextPage.NavigateUrl = String.Concat("select.aspx?CurrentPage=","",intPageNo+1);
HLEndPage.NavigateUrl = String.Concat("select.aspx?CurrentPage=","",intPageCount);
}
else
{
HLNextPage.NavigateUrl = "";
HLEndPage.NavigateUrl = "";
//HLNextPage.Enabled=false;
//HLEndPage.Enabled=false;
}

}

</script>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<head>
<link href="/style.css" rel="stylesheet" />
<style type="text/css">
.high { font-family: "宋体"; font-size: 9pt; line-height: 140%}
.mid { font-size: 9pt; line-height: 12pt}
.small { font-size: 9pt; line-height: normal}
.TP10_5 {
font-size: 14px;
line-height: 140%;
}
</style>
<style type="text/css">A:link {
COLOR: #cc6666
}
</style>
</head>
<body>
<form runat="server">
<span class="high"> 第<font color="#CC0000"><asp:Label id="LabelRow" runat="server"/></font>页 | 共有<asp:Label id="LabelPage" runat="server"/>页
| <asp:Label id="LabelRecord" runat="server"/>条信息 |
<asp:HyperLink id="HLFistPage" Text="首页" runat="server"/>
| <asp:HyperLink id="HLPrevPage" Text="上一页" runat="server"/>
| <asp:HyperLink id="HLNextPage" Text="下一页" runat="server"/>
| <asp:HyperLink id="HLEndPage" Text="尾页" runat="server"/></span><br>

<asp:Repeater id=Repeater runat="server">

<HeaderTemplate>

<table width="583" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#000000"><table width="100%" border="0" cellpadding="4" cellspacing="1" class="TP10_5">
<tr bgcolor="#999999">
<td align="center"> <strong><font color="#FFFFFF">订单号</font></strong></td>
<td align="center"> <strong><font color="#FFFFFF">服务项目</font></strong></td>
<td align="center"> <strong><font color="#FFFFFF">预订日期</font></strong></td>
<td align="center"> <strong><font color="#FFFFFF">操作人员</font></strong></td>
<td align="center"> <strong><font color="#FFFFFF">分配状态</font></strong></td>
<td> <div align="center"></div></td>
</tr>
</HeaderTemplate>

<ItemTemplate>

<tr align="center" bgcolor="#FFFFFF" class="small" ,
@SPintEndID=@intEndID,@SPintBeginID=@intBeginID

return(@@rowcount)
--select @@rowcount
GO

时间: 2024-08-03 00:59:01

ASP.NET结合存储过程写的通用搜索分页程序的相关文章

asp.net调用存储过程往oracle写clob字段?急死了,弄两天了。。

问题描述 asp.net调用存储过程往oracle写clob字段?急死了,弄两天了..在页面上有一个FCK编辑器可以取VALUE值,然后我把他转化成string类型,调用存储过程来往oracle的clob字段插数据,可是value值大的时候,当然没超过1M,提示转换错误,为什么呢?难道这里的clob不能调用存储过程来写?谁有好的办法,马上结帖!!! 解决方案 解决方案二:在网上找的都是直接insert语句,难道不能调用存储过程吗,我的insert语句是在存储过程里,怎么调用存储过程来写clob字

Dreamweaver开发ASP实例视频教程(12)复杂站内搜索

dreamweaver|教程|视频教程 本视频教程由本站合作网站陶益数码工作室http://www.ty502.com推出,欢迎大家访问他们的网站. 使用Dreamweaver开发ASP具有不用手工写代码的优点,非常适合初学者建设自己的动态网站.本套教程由我们精心设计奉献给大家,内容包含了文章整站教程.音乐整站教程.图片整站教程.文件上传系统教程.投票系统教程.会员分级管理系统教程和网站后台管理教程等,通过本教程的学习,相信您一定能很快掌握动态网站制作的方法,从代码的枯燥乏味中解脱出来. 教程介

Dreamweaver开发ASP实例视频教程(11)简单站内搜索页

dreamweaver|教程|视频教程 本视频教程由本站合作网站陶益数码工作室http://www.ty502.com推出,欢迎大家访问他们的网站. 使用Dreamweaver开发ASP具有不用手工写代码的优点,非常适合初学者建设自己的动态网站.本套教程由我们精心设计奉献给大家,内容包含了文章整站教程.音乐整站教程.图片整站教程.文件上传系统教程.投票系统教程.会员分级管理系统教程和网站后台管理教程等,通过本教程的学习,相信您一定能很快掌握动态网站制作的方法,从代码的枯燥乏味中解脱出来. 教程介

ASP调用MSSQL存储过程并返回记录集源码详解

存储过程|记录集|详解 以下是asp代码(demo.asp):<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!--#include file="adovbs.inc"--> <% '通用的ASP读取MSSQL存储过程代码示例 '返回临时表记录集 '带传递参数 dim conn,connstr,cmd,rs connstr = "Provider=SQLOLEDB;serv

关于ASP.NET 调用存储过程传参数的问题

问题描述 关于ASP.NET 调用存储过程传参数的问题 /// /// 执行存储过程 /// /// 存储过程名 /// 存储过程参数 /// SqlDataReader public static SqlDataReader RunProcedure(string storedProcName, IDataParameter[] parameters) { SqlConnection connection = OpenSqlConnection(); SqlCommand command =

我从dreamweaver拿来一个网页加入到asp.net中为什么写了事件但不响应?

问题描述 我从dreamweaver拿来一个网页加入到asp.net中为什么写了事件但不响应?如果有办法请详细点说,我是新手.谢谢 解决方案 解决方案二:ding解决方案三:<@Pagelanguage=c#AutoEventWireup="false"Inherits="XXX"%>AutoEventWireup="false"中false表示不调用自动调用页事件,即Page_Init和Page_Load方法.把AutoEventW

用ASP的方法动态写出JavaScript的表单验证的函数checkSubmit()

javascript|表单验证|动态|函数 <%'请转存为CheckForm_JS.asp使用 '*****************************************************************************'函数名称:CheckForm_JS(frmName,errStr)'功能:用ASP的方法动态写出JavaScript的表单验证的函数checkSubmit()'使用方法:1.<!--Include File=URL+本函数所在的页>;' 

学会在ASP中使用存储过程

存储过程|存储过程 学习使用存储过程(Stored Procedure),是ASP程序员的必须课之一.所有的大型数据库都支持存储过程,比如Oracle.MS SQL等,(但MS Access不支持,不过,在Access里可以使用参数化的查询).使用存储过程有许多好处,它可以封装复杂的数据逻辑,充分发挥大型数据库本身的优势.我们知道,ASP并不适合做复杂的数据运算,而通过OLD DB访问数据库,由于数据需要在ASP和数据库之间传递,相当消耗系统资源.事实上,如果数据库仅仅起着数据存储的作用,那么它

ASP中使用存储过程

存储过程|存储过程 学习使用存储过程(Stored Procedure),是ASP程序员的必须课之一. 所有的大型数据库都支持存储过程,比如Oracle.MS SQL等,(但MS Access不支持,不过,在Access里可以使用参数化的查询). 存储过程是利用SQL Server所提供的Tranact-SQL语言所编写的程序.Tranact-SQL语言是SQL Server提供专为设计数据库应用程序的语言,它是应用程序和SQL Server数据库间的主要程序式设计界面.它好比Oracle数据库