打开数据库
<
%
' OnErrorResumeNext
Set conn = Server.CreateObject( " ADODB.Connection " )
connstr = " Provider=Microsoft.Jet.OLEDB.4.0;DataSource= " & Server.MapPath( " data/db.mdb " )
conn.openconnstr
% >
' OnErrorResumeNext
Set conn = Server.CreateObject( " ADODB.Connection " )
connstr = " Provider=Microsoft.Jet.OLEDB.4.0;DataSource= " & Server.MapPath( " data/db.mdb " )
conn.openconnstr
% >
关闭数据库
<
%
conn.close
set conn = nothing
% >
conn.close
set conn = nothing
% >
修伽i数据库信息
<
%
' 插入
sql = " INSERTINTObranchtype(branchname,sj)VALUES(' " & branchname & " ',' " & now () & " ') "
conn.execute(sql)
' 修改
sql = " updatebranchtypesetbranchname=' " & branchname & " 'wherebranchid= " & clng (branchid)
conn.execute(sql)
' 删除
sql = " delete*fromnewslistwhereid= " & id
conn.execute(sql)
' 插入
sql = " INSERTINTObranchtype(branchname,sj)VALUES(' " & branchname & " ',' " & now () & " ') "
conn.execute(sql)
' 修改
sql = " updatebranchtypesetbranchname=' " & branchname & " 'wherebranchid= " & clng (branchid)
conn.execute(sql)
' 删除
sql = " delete*fromnewslistwhereid= " & id
conn.execute(sql)
读取数据库信息并显示
'
无分页显示
sql = " selectbranchnamefrombranchtypewherebranchid= " & branchid
set rs = conn.execute(sql)
if not rs.eof then
do while not rs.eof
response.writers( " branchname " ) & " <br/> "
rs.movenext
loop
else
response.write " 对不起,没有数据 "
end if
set rs = nothing
' 分页显示
set rs = server.createobject( " adodb.recordset " )
rs.opensql,conn, 1 , 1
if not rs.eof then
rs.PageSize = 16 ' 每页显示的数据条数
page = request( " page " )
if isnumeric (page) = false then
page = 1
elseif page = "" then
page = 1
end if
page = clng (page)
if page > rs.pagecount then
page = rs.pagecount
end if
rs.AbsolutePage = page
for i = 1 to rs.pagesize
if rs.eof or rs.bof then
exit for
end if
response.writers( " branchname " ) & " <br/> "
rs.movenext
next
if rs.pagecount > 1 then
% >
< % if page <> 1 then % > < ahref =< % = webpage% > page = 1 title = 首页 > 首页 </ a >< % else % >< fontcolor = dcdcdc > 首页 </ font > < % end if % >
< % if page > 10 then % > < ahref =< % = webpage% > page =< % = page - 10 % > title = 上十页 > 上十页 </ a >< % else % >< fontcolor = dcdcdc > 上十页 </ font > < % end if % >
< % if page > 1 then % > < ahref =< % = webpage% > page =< % = page - 1 % > title = 上一页 > 上一页 </ a >< % else % >< fontcolor = dcdcdc > 上一页 </ font > < % end if % >
共 < % = rs.recordcount% > 条数据共 < % = rs.pagecount% > 页当前第 < % = page% > 页
< % if page < rs.pagecount then % > < ahref =< % = webpage% > page =< % = page + 1 % > title = 下一页 > 下一页 </ a >< % else % >< fontcolor = dcdcdc > 下一页 </ font > < % end if % >
< % if page < rs.pagecount - 10 then % > < ahref =< % = webpage% > page =< % = page + 10 % > title = 下十页 > 下十页 </ a >< % else % >< fontcolor = dcdcdc > 下十页 </ font > < % end if % >
< % if page <> rs.pagecount then % > < ahref =< % = webpage% > page =< % = rs.pagecount% > title = 末页 > 末页 </ a >< % else % >< fontcolor = dcdcdc > 末页 </ font > < % end if % >
< %
end if
else
response.write " 对不起,没有数据 "
end if
rs.close
set rs = nothing
% >
sql = " selectbranchnamefrombranchtypewherebranchid= " & branchid
set rs = conn.execute(sql)
if not rs.eof then
do while not rs.eof
response.writers( " branchname " ) & " <br/> "
rs.movenext
loop
else
response.write " 对不起,没有数据 "
end if
set rs = nothing
' 分页显示
set rs = server.createobject( " adodb.recordset " )
rs.opensql,conn, 1 , 1
if not rs.eof then
rs.PageSize = 16 ' 每页显示的数据条数
page = request( " page " )
if isnumeric (page) = false then
page = 1
elseif page = "" then
page = 1
end if
page = clng (page)
if page > rs.pagecount then
page = rs.pagecount
end if
rs.AbsolutePage = page
for i = 1 to rs.pagesize
if rs.eof or rs.bof then
exit for
end if
response.writers( " branchname " ) & " <br/> "
rs.movenext
next
if rs.pagecount > 1 then
% >
< % if page <> 1 then % > < ahref =< % = webpage% > page = 1 title = 首页 > 首页 </ a >< % else % >< fontcolor = dcdcdc > 首页 </ font > < % end if % >
< % if page > 10 then % > < ahref =< % = webpage% > page =< % = page - 10 % > title = 上十页 > 上十页 </ a >< % else % >< fontcolor = dcdcdc > 上十页 </ font > < % end if % >
< % if page > 1 then % > < ahref =< % = webpage% > page =< % = page - 1 % > title = 上一页 > 上一页 </ a >< % else % >< fontcolor = dcdcdc > 上一页 </ font > < % end if % >
共 < % = rs.recordcount% > 条数据共 < % = rs.pagecount% > 页当前第 < % = page% > 页
< % if page < rs.pagecount then % > < ahref =< % = webpage% > page =< % = page + 1 % > title = 下一页 > 下一页 </ a >< % else % >< fontcolor = dcdcdc > 下一页 </ font > < % end if % >
< % if page < rs.pagecount - 10 then % > < ahref =< % = webpage% > page =< % = page + 10 % > title = 下十页 > 下十页 </ a >< % else % >< fontcolor = dcdcdc > 下十页 </ font > < % end if % >
< % if page <> rs.pagecount then % > < ahref =< % = webpage% > page =< % = rs.pagecount% > title = 末页 > 末页 </ a >< % else % >< fontcolor = dcdcdc > 末页 </ font > < % end if % >
< %
end if
else
response.write " 对不起,没有数据 "
end if
rs.close
set rs = nothing
% >