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=="首页")
{
CurPageNum = 1;
}else if(up=="上一页")
{
toppage = uppage;
//Response.Write("<mce:script type="text/javascript"><!--
alert('"+toppage+"');
// --></mce:script>");
CurPageNum = toppage-1;
//Response.Write("<mce:script type="text/javascript"><!--
alert('"+CurPageNum+"');
// --></mce:script>");
if(CurPageNum <= 0)
{
CurPageNum = 1;
}
}else if(down=="下一页")
{
toppage = downpage;
//Response.Write("<mce:script type="text/javascript"><!--
alert('"+toppage+"');
// --></mce:script>");
CurPageNum = toppage+1;
//Response.Write("<mce:script type="text/javascript"><!--
alert('"+CurPageNum+"');
// --></mce:script>");
if (CurPageNum >= TotalPages)
{
CurPageNum = TotalPages;
}
}
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
相关文档:
JS中数组的批量填充方式:
1.在声明时同时进行填充
var beatles = Array("John","Paul","George","Ringo");
2.我们甚至用不着明确地表明我们是在创建数组.事实上,只需用一堆方括号括起来就足以创建我们想要的数组了:
......
Java代码 import flash.external.ExternalInterface; function hello(){ return "测试成功了哦~~"; } //允许flash调用js函数 参数1:js函数名称 参数2:向js函数传递的参数 ExternalInterface.call("hello", "jacky"); ......
第一种 JavaScript连接数据库:
<mce:script language="JavaScript"><!--
// 创建数据库对象
var objdbConn = new ActiveXObject("ADODB.Connection");
// DSN字符串
var strdsn = "Driver={SQL Server};SERVER=192.168.0.210;UID=xhb;PWD=xhb;DATABASE=books";
// 打开数据源
objdbConn.Open(strdsn);
// ......
//总记录数
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, ......