如何在asp页面中为access数据库表添加字段并定义字段的数据类型?

哈特比尔波 2009-04-15 02:05:48
问题如题!我现在具体的就有一个连接数据库的页面一个用户可以填写要添加的那个字段和类型?请问如何在单击提交以后跳转的那个页面处理向数据库表添加相应的字段和字段类型。谢谢!
下面是我的一些代码。请大家帮忙修改。
连接数据库的页面conn.asp
代码如下:
<%
Set conn = Server.CreateObject("ADODB.Connection")
Strconn="DRIVER={Microsoft Access Driver (*.mdb)}; "
Strconn=Strconn & "DBQ=" & Server.MapPath("rck.mdb")
conn.Open Strconn
%>
用户填写的界面文件jiegou.asp
代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<p align="center">数据库表结构修改页面</p>
<form id="form1" name="form1" method="post" action="biaojiegou.asp">
需要添加的字段名:
<label>
<input type="text" name="ziduan" id="ziduan" />
</label>
字段类型:
<label>
<input type="text" name="leixing" id="leixing" />
</label>
<p>
<label>
<input type="submit" name="button" id="button" value="提交" />
</label>
<label>
<input type="reset" name="button2" id="button2" value="取消" />
</label>
</p>
</form>
</body>
</html>
提交转向处理的页面biaojiegou.asp
代码如下:
<%
response.Buffer = true
dim ziduan
ziduan=trim(request.Form("ziduan"))
sql="alter table ybqh add= '"&ziduan&"'"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,Strconn,1,3
rs.close
set rs=nothing
set Strconn=nothing
conn.close
response.Redirect"index.asp"
%>
现在问题就是这个处理页面上的具体的向access数据库表写入字段的代码不知道如何写,请各位csdn的朋友帮帮忙!谢谢了!
...全文
160 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
pc1780 2009-04-15
  • 打赏
  • 举报
回复
观看

28,409

社区成员

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

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