JavaScript连接SqlServer并实现分页
//总记录数
function sumRecord()
{
var conn= Server.CreateObject("ADODB.connection");
var rs= Server.CreateObject("adodb.recordset");
conn.open("PROVIDER=SQLOLEDB;DATA SOURCE=127.0.0.1;UID=sa;PWD=123456;DATABASE=test");
var sql = "select count(*) as RecordCount from baoming";
rs.open(sql,conn);
TotalRecords = rs('RecordCount');
}
function baoming()
{
//计算总的页数
TotalPages = (((TotalRecords % PageSize) == 0) ? (TotalRecords / PageSize)
: (TotalRecords / PageSize + 1));
//获取传参过来的页数
var toppage;
var home = Request.Form("home");
var up = Request.Form("up");
var uppage = parseInt(Request.Form("uppage"));
var down = Request.Form("down");
var downpage = parseInt(Request.Form("downpage"));
if(home=="首页")
{
PageSize=30;
}else if(up=="上一页")
{
toppage = uppage;
if(toppage !=0)
{
CurPageNum = toppage;
if (CurPageNum > TotalPages)
{
CurPageNum = TotalPages;
} else if (CurPageNum <= 0)
{
showCurPageNumPage = 1;
}
}
}else if(down=="下一页")
{
toppage = downpage;
if(toppage !=0)
{
CurPageNum = toppage;
if (CurPageNum > TotalPages)
{
CurPageNum = TotalPages;
} else if (CurPageNum <= 0)
{
showCurPageNumPage = 1;
}
}
}
//rs.Absolute((CurPageNum - 1) * PageSize + 1);
var conn= Server.CreateObject("ADODB.connection");
var rs= Server.CreateObject("adodb.recordset");
conn.open("PROVIDER=SQLOLEDB;DATA SOURCE=127.0.0.1;UID=sa;PWD=123456;DATABASE=test");
var sql = "select top "+PageSize+" truename,activeid,chrtel,CONVERT(varchar(30),dtappenddate,20) as dtappenddate from baoming where id not in(select top "+(PageSize*(CurPageNum-1))+" id from baoming order by id desc) order by id desc";
rs.open(sql,conn);
var i =0;
if(TotalRecords < 1)
{
Response.write("<mce:script type="text/javascript"><!--
alert('没有记录');
// --></mce:scri
相关文档:
这个系列文章主要是讲述实现Javascript拖拽功能的基础知识,并将在最后给出一个完整的示例。适合对拖拽完全不懂的人阅读。
第一篇就先讲讲Javascript中的offsetParent属性吧。
支持的浏览器:Internet Explorer 4.0+,Mozilla 1.0+,Netscape 6.0+,Opera 7.0+,Safari ......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Wanna tell her - interactive DHTML </title>
<meta http-equiv="imagetoolbar" content="no">
<style type="text/css">
html {
overflow: h ......
JS中数组的批量填充方式:
1.在声明时同时进行填充
var beatles = Array("John","Paul","George","Ringo");
2.我们甚至用不着明确地表明我们是在创建数组.事实上,只需用一堆方括号括起来就足以创建我们想要的数组了:
......
sqlServer:
一次查询,数据库只返回一页的数据。而不是取出所有的数据。
pagesize: 每页显示记录数
cureentpage:当前页数
select * from ( select TOP pagesize * from ( SELECT TOP pagesize*cureentpage * from my_table ORDER BY id ASC ) as amyTable OR ......