如今,cgi日渐衰落,asp大行其道,大有取而代之之势。对个人主页制作者而言,cgi也确实太复杂了,尤其是在数据库的操作上,繁复无比让人望而生畏。相较而言, asp则简单得多。其面向对象的思想,将复杂的底层操作掩盖,只留下简单的调用接口。对数据库的操作更是将它的优点体现得淋漓尽致。
本文将简单介绍在个人主页中运用asp连接数据库,实现动态网页。相信您在读完本文后,您的主页将更加精彩。
1.在asp中查询access 数据库
asp能让我们用简单的方法在网页中查询、更新数据库。下面将给出的例子用的是ms access database,但是其操作的原理却可同样地运用在任何支持odbc的数据库上。(之所以选择access,是因为它容易操作,且被广泛使用,对大多数的中小型项目而言,access无疑是最好的选择。)
先用access建立一个数据表如下:
| 用户编号 | 姓名 | 城市 | 电话号码 |
| 1 | 张三 | 武汉 | 027-84713858 |
| 2 | 李四 | 北京 | 010-99581426 |
| 3 | 王五 | 上海 | 021-85541253 |
| <% set dbconnection=server.createobject(“adodb.connection”) dbconnection.open “dsnname” sqlquery=“select * from customers” set recustionmerlist=dbconnection.execute(sqlquery) %> < center> < table border=1> < % do while not recustomerlist.eof %> < tr> < td><%=recustomerlist(“客户编号”)%>< /td> < td><%=recustomerlist(“姓名”)%>< /td> < td><%=recustomerlist(“城市”)%>< /td> < td><%=recustomerlist(“电话号码”)%>< /td> < /tr> < % recustomerlist.movnext loop %> < /table> < /center> |
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器