首页 »XML教程 » 数据库服务器:用XML结合数据库,给服务器减负二 »正文
数据库服务器:用XML结合数据库,给服务器减负二
来源: 发布时间:星期五, 2008年9月26日 浏览:89次 评论:0
我们的思路是:
1.客户端向服务器的某个ASP程序发出查询条件。 2.该ASP程序响应,并连接数据库。 3.数据库将查询结果返回给该ASP程序。 4.获得数据后,用ASP程序将数据格式化为XML格式, 从而将查询结果建立为该ASP的内嵌式XML对象。 5.在客户端实现XML的分页(分页方法类似于数据库分页) 6.此后,无论是客户端将查询结果翻多少页看多少遍,均不会再与服务器发生交互。 另外,就算是客户端断开网线,也仍然可以浏览还未浏览的分页页面。
下面是我写的一个歌曲在线播放程序页面程序,由两个文件构成: songList.mdb 一个数据库,装载着歌曲信息。 songList.asp ASP程序,数据库中的数据格式成XML,页面完全显示后,无论点多少次 “下一首”,也不会与服务器交互。
◆songList.asp◆ 点击后面的链接查看实例 查看
<html> <head> <title>殷亮的在线播放</title> <style type=\"text/css\"> <!-- .input { background-color: #000000; border: #000000; color: #FF9900; } --> </style> </head>
<body bgcolor=\"#000000\" text=\"#FF9900\"> <% \'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'连接数据库\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\' set songCon = Server.CreateObject(\"ADODB.connection\") conPath = Server.MapPath(\"songList.mdb\") conStr = \"DRIVER={Microsoft Access Driver (*.mdb)}; dbq=\" songCon.open(conStr & conPath) set rs = Server.CreateObject(\"ADODB.Recordset\") rs.open \"Select * from songList\",songCon,3,3 %>
<!--动态生成内嵌式XML文档,\"在线播放\"是根标记--> <xml id = \"xmlFile\"> <在线播放> <% If not rs.eof then while not rs.eof %> <歌曲> <歌名><%= trim(rs(\"song_name\")) %></歌名> <URL><%= trim(rs(\"song_url\")) %></URL> <演唱者><%= trim(rs(\"songer\")) %></演唱者> <歌词><%= trim(rs(\"song_lyrics\")) %></歌词> </歌曲> <% rs.movenext wend End If %> </在线播放> </xml> <div id=\"Layer1\" style=\"position:absolute; width:500px; height:59px; z-index:1; left: 118px; top: 4px;\"> <!--Window Media Player控件--> <OBJECT classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" width=\"500\" height=\"43\" id=\"player\" style=\"WIDTH: 500px; HEIGHT: 43px\" VIEWASTEXT> <PARAM NAME=\"AudioStream\" VALUE=\"-1\"> <PARAM NAME=\"AutoSize\" VALUE=\"0\"> <PARAM NAME=\"AutoStart\" VALUE=\"-1\"> <PARAM NAME=\"AnimationAtStart\" VALUE=\"-1\"> <PARAM NAME=\"AllowScan\" VALUE=\"-1\"> <PARAM NAME=\"AllowChangeDisplaySize\" VALUE=\"-1\"> <PARAM NAME=\"AutoRewind\" VALUE=\"0\"> <PARAM NAME=\"Balance\" VALUE=\"0\"> <PARAM NAME=\"BaseURL\" VALUE=\"\"> <PARAM NAME=\"BufferingTime\" VALUE=\"5\"> <PARAM NAME=\"CaptioningID\" VALUE=\"\"> <PARAM NAME=\"ClickToPlay\" VALUE=\"-1\"> <PARAM NAME=\"CursorType\" VALUE=\"0\"> <PARAM NAME=\"CurrentPosition\" VALUE=\"-1\"> <PARAM NAME=\"CurrentMarker\" VALUE=\"0\"> <PARAM NAME=\"DefaultFrame\" VALUE=\"\"> <PARAM NAME=\"DisplayBackColor\" VALUE=\"0\"> <PARAM NAME=\"DisplayForeColor\" VALUE=\"16777215\"> <PARAM NAME=\"DisplayMode\" VALUE=\"0\"> <PARAM NAME=\"DisplaySize\" VALUE=\"4\"> <PARAM NAME=\"Enabled\" VALUE=\"-1\"> <PARAM NAME=\"EnableContextMenu\" VALUE=\"-1\"> <PARAM NAME=\"EnablePositionControls\" VALUE=\"-1\"> <PARAM NAME=\"EnableFullScreenControls\" VALUE=\"0\"> <PARAM NAME=\"EnableTracker\" VALUE=\"-1\"> <PARAM NAME=\"Filename\" VALUE=\"\"> <PARAM NAME=\"InvokeURLs\" VALUE=\"-1\"> <PARAM NAME=\"Language\" VALUE=\"-1\"> <PARAM NAME=\"Mute\" VALUE=\"0\"> <PARAM NAME=\"PlayCount\" VALUE=\"1\"> <PARAM NAME=\"PreviewMode\" VALUE=\"0\"> <PARAM NAME=\"Rate\" VALUE=\"1\"> <PARAM NAME=\"SAMILang\" VALUE=\"\"> <PARAM NAME=\"SAMIStyle\" VALUE=\"\"> <PARAM NAME=\"SAMIFileName\" VALUE=\"\"> <PARAM NAME=\"SelectionStart\" VALUE=\"-1\"> <PARAM NAME=\"SelectionEnd\" VALUE=\"-1\"> <PARAM NAME=\"SendOpenStateChangeEvents\" VALUE=\"-1\"> <PARAM NAME=\"SendWarningEvents\" VALUE=\"-1\"> <PARAM NAME=\"SendErrorEvents\" VALUE=\"-1\"> <PARAM NAME=\"SendKeyboardEvents\" VALUE=\"0\"> <PARAM NAME=\"SendMouseClickEvents\" VALUE=\"0\"> <PARAM NAME=\"SendMouseMoveEvents\" VALUE=\"0\"> <PARAM NAME=\"SendPlayStateChangeEvents\" VALUE=\"-1\"> <PARAM NAME=\"ShowCaptioning\" VALUE=\"0\"> <PARAM NAME=\"ShowControls\" VALUE=\"-1\"> <PARAM NAME=\"ShowAudioControls\" VALUE=\"-1\"> <PARAM NAME=\"ShowDisplay\" VALUE=\"0\"> <PARAM NAME=\"ShowGotoBar\" VALUE=\"0\"> <PARAM NAME=\"ShowPositionControls\" VALUE=\"-1\"> <PARAM NAME=\"ShowStatusBar\" VALUE=\"0\"> <PARAM NAME=\"ShowTracker\" VALUE=\"-1\"> <PARAM NAME=\"TransparentAtStart\" VALUE=\"0\">
相关文章
读者评论
发表评论
|
|