ASP通用数据库显示编辑程序

csdncb 2004-04-02 11:40:28
[引言:]我是虽然半路出家经作了几年的程序,但不知自己是否算是一个程序员。我最近帮朋友作一个网站,为了空间的便宜,选用了ASP+ACCESS的服务器。由于本人对ASP知道很少,所以实在做得有点累,特别是后台数据库的管理,有一大堆的表需要我日常维护。我发现,对于后台数据管理,基本上对数据库进行增删改查的的操作,我一个表一个表的写同样的操作,真的无法忍受。上网查了查,还真有通用的数据显示程序,可惜没有数据编辑功能。于是有了自己写一个通用的功能的想法。下面是我参考网友*后的实现。
[设计目标:]
1、数据库显示,编辑,增加,修改,且可以由用户定义选用。
2、显示的字段列可以用户定义(显示名称可自定义)
3、页面的显示格式以由用户定义,这包括每页记录数,页脚,列宽,表格的样式(配置了格式控制CSS文件)
4、组件的界面,支持多语言(chinese,eng,...),可惜还未有时间实现,现为中文。
5、支持多表联合查询
[缺限:]
调用参数复杂,需要文档支持,多表联合查询别名有限制。

[使用示例:]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="./style_cn.css" type=text/css rel=stylesheet>

<title>通用数据库显示程序</title>

</head>
<body bgcolor="#66cccc">
<%
'多个字段用数组表示
'DSN连接写法
'sConn = "DSN=<数据库名>;UID=<DSN账号>;PWD=<密码>"
'使用物理路径连接Access数据库写法
'sConn = "DBQ=" & Server.MapPath("<Access数据库文件的当前文件相对路径>") & ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
'连接SQLServer写法
'sConn = "Provider=SQLOLEDB;Persist Security Info=False;UID=<用户名>;PWD=<密码>;Initial Catalog=<SQLServer数据库名>;Data Source=<数据服务器IP>"

Dim sConn, sTableName, sHidden, sDisplay, sQuery, sOrder, iTop, iPageSize,sEditCols,sKey,sRelation,sColWidth
sConn = "DBQ=" & Server.MapPath("sample.MDB") & ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"

'sTableName = "客户"
'sDisplay = "联系人姓名 | 联系人 | <a href=""view.asp?CustomerID=$客户ID$"">$联系人姓名$</a>, 公司名称|公司, 联系人头衔|称谓, 地址, 城市"
'sHidden = "客户ID"
'sQuery = "联系人姓名 | 联系人, 公司名称|公司, 联系人头衔|称谓 , 城市"
'sOrder = "客户ID"
'iTop = 300
'iPageSize = 2
'sEditCols="0,1,1,1,1"'0-not edit ,1-edit
'sKey="客户(客户ID);"
'sRelation=""


sTableName = "Customer,myOrder"
sDisplay = "myOrder.custid|客户ID|<a href=""view.asp?CustomerID=myOrder.custid$"">$CustName$</a>, lineid|行号,product|产品,qty|数量,Amt|金额,dt|日期,linenotes|备注"
sHidden = "CustName"
sQuery = "myOrder.CustID|客户ID, product|产品, dt|定单日期"
sOrder = "myOrder.lineID"
iTop = 300
iPageSize = 2
sEditCols="0,1,1,1,1,1,1"'0-not edit ,1-edit
sKey="myOrder(myOrder.custid,lineid);"
sRelation=" myOrder.custid=customer.custid "
sColWidth="20,40,60,60,60,60,60"

'DisplayTable sConn, sTableName, sHidden, sDisplay, sQuery, sOrder, iTop, iPageSize
dim objTable
Set objTable= New clsDispalyTable

'response.Write sConn & "<br>"
objTable.SetTablePara sConn, sTableName, sHidden, sDisplay, sQuery, sOrder,sRelation,sKey
objTable.SetEditPara sEditCols,"",sColWidth,True,True,True
objTable.SetPagePara 300,3
Response.write "<table border=0 align=center cellspacing=0 cellpadding=0><tr><td bgcolor=#6699cc>"
objTable.DisplayTable
Response.write "</td></tr><table>"

'pConn, pTableNames, pHidden, pDisplay, pQuery,pOrder,pRelation,pKeys)


%>

演示:http:www.qinych.com/caibing/test/test.asp


文章:<a href="http://www.xurui.com/mypaper/通用数据库显示程序">通用数据库显示程序文章</a><br>
示例asp程序:<a href="http://www.xurui.com/mypaper/通用数据库显示程序/common.asp">http://www.xurui.com/mypaper/通用数据库显示程序/common.asp</a><br>
示例数据库地址:<a href="http://www.xurui.com/mypaper/通用数据库显示程序/sample.mdb">http://www.xurui.com/mypaper/通用数据库显示程序/sample.mdb</a>
</body>
</html>
[小结:] 虽然已经完成了了大部分功能,但还有很多不完美的地言,肯请朋友提出意见。
Email:bingcaicai@sina.com

可以从演示程序处下载源码!

演示:http://www.qinych.com/caibing/test/test.asp





...全文
143 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wanliang2001 2004-04-04
  • 打赏
  • 举报
回复
象雷峰同志,及其战友学习!!!
csdncb 2004-04-04
  • 打赏
  • 举报
回复
to: 51windows(海娃)
谢谢你给了我一个非常好的URL。
我认为你对这个问题肯定有研究!
我觉得我的工作和UTE有相似之处,也有不同之处。
我想认真的将我的工作再做一做,不之能否给一些建议。
谢谢!
51windows 2004-04-03
  • 打赏
  • 举报
回复
可以参考一下这个

Insert, edit and delete records in a table.
Define any number of filters to shorten the number of records.
Export complete table content as .CSV file.
Show the exact field definitions.
Sorting of each column.
Automatic primary key detection.
Display the currently used SQL statement to read the datas from the Database.
UTE is one VBScript class with some few easy to use public properties and functions.
In action UTE is controlled via URL parameters.
The layout is completely style sheet driven.
All displayed strings are defined in a special language include file.
Error management.
UTE is option explicit proof.
Binary Data types will not be displayed and are not editable.



http://www.codeproject.com/asp/ute.asp

不能链接请在这儿下载
http://www.51windows.net/myfile/rar/ute_301.zip

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧