如何使用表格来储存数据库的记录?

时间:2010-05-16 15:14:00 

我见到有的网站好像可以把数据库的记录读到表格里去,是这样的吗?如何做到的?

可能是这样的,因为我们确实能把数据库里的记录用表格来储存,看看下面的办法:

<html>
<head>
<TITLE>用表格储存数据 - aspxhome.com</TITLE>
</head>
<body>
<% 
myDSN="DSN=Student;uid=student;pwd=magic"
mySQL="select * from publishers where state='NY'"
showblank="&nbsp;"
shownull="-null-"
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
set rstemp=conntemp.execute(mySQL)
If  rstemp.eof then
   response.write "对不起,暂无匹配记录,请再检查一遍<br>"
   response.write mySQL & "<br>对不起,无法创建表格……"
   conntemp.close
   set conntemp=nothing
   response.end
end if
%>
<table border=1><tr>
<%
for each whatever in rstemp.fields%>
       <td><b><%=whatever.name%></B></TD>
<% next %>
' 把标题写到表格名称栏
</tr>
<%
DO  UNTIL rstemp.eof %>
   <tr>
   <% for each whatever in rstemp.fields
      thisfield=whatever.value
      if isnull(thisfield) then
         thisfield=shownull
' 读取全部记录
      end if
      if trim(thisfield)="" then
         thisfield=showblank
      end if%>
             <td valign=top><%=thisfield%></td>
   <% next %>
   </tr>
   <%rstemp.movenext
LOOP%>
</table>
<%
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
%>
</body>
</html>

标签:表格,数据库,存储
0
投稿

猜你喜欢

  • 一个ASPJPEG组件的asp类 CLASS

    2008-03-11 12:22:00
  • 写出完美CSS代码的5个重要方面

    2009-12-30 16:44:00
  • SQL的Join使用图解教程

    2012-08-21 10:47:23
  • asp如何用ADO批量更新记录?

    2010-06-10 18:42:00
  • CSS隐藏文字的方法

    2008-10-03 12:08:00
  • Asp无组件生成缩略图

    2007-10-26 12:08:00
  • Mootools常用方法扩展(二)

    2009-01-11 18:22:00
  • 如何解决AJAX中跨域访问出现'没有权限'的错误

    2008-09-11 17:20:00
  • 页面中图像格式的选用之我见

    2007-10-31 18:11:00
  • 如何判断发言是否为空?

    2010-01-12 20:15:00
  • 微型设计专用工具Dorado

    2011-01-06 12:23:00
  • ASP中双引号单引号和&连接符使用技巧

    2007-10-01 18:20:00
  • XML编程实例:用ASP+XML打造留言本

    2008-05-04 13:37:00
  • FrontPage服务器扩展

    2008-03-05 13:05:00
  • MySQL的之表结构修改

    2012-01-05 19:16:17
  • oracle的一些tips技巧

    2009-03-02 11:06:00
  • 省市级联菜单的可用性

    2009-02-24 16:32:00
  • 数据库主键的故事

    2008-05-31 07:50:00
  • my.ini(my.cnf)与mysql优化指南

    2009-12-15 16:20:00
  • 技巧/诀窍:在ASP.NET中重写URL

    2007-09-23 12:21:00
  • asp之家 网络编程 m.aspxhome.com