当前位置: 网学 > 编程文档 > ASP > 正文

在线数据库管理工具(db007) v1.5

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/17
then
table = request("table_name")
echo "以下是表 <font color=red>" & request("table_name") & "</font> 的结构: "
echo "<input type=''button'' name=''ok'' value='' 返 回 '' onClick=''javascript:history.go(-1)''>"
strsql = getsql(table)
end if
if strt = "2" then
echo "以下是 <font color=red> 数据库 </font> 的结构: "
echo "<input type=''button'' name=''ok'' value='' 返 回 '' onClick=''javascript:history.go(-1)''>"
set objSchema = Conn.OpenSchema(adSchemaTables)
Do While Not objSchema.EOF
if objSchema("TABLE_TYPE") = "TABLE" then
table = objSchema("TABLE_NAME")
strsql = strsql & getsql(table)''table & "|"''getsql(table)
end if
objSchema.MoveNext
Loop
objSchema.close
end if
echo "<textarea cols=110 rows=38>" & strsql & "</textarea>"
conn.close
end sub

''================================================================== 输出表结构
function getsql(table)
on error resume next
getsql = "-- 表结构 " & table & " 的SQL语句。" & chr(10)
dim primary,primarykey
Set primary = Conn.OpenSchema(adSchemaPrimaryKeys,Array(empty,empty,table))
if primary("COLUMN_NAME") <> "" then
primarykey = primary("COLUMN_NAME")
end if

primary.Close
set primary = nothing

tbl_struct = "CREATE TABLE [" & table & "] ( " & chr(10)
sql = "SELECT * FROM " & table
Set rs = Conn.Execute(sql)
if err = 0 then
for i = 0 to rs.fields.count-1
tbl_struct = tbl_struct & "[" & rs(i).name & "] "
typs = typ(rs(i).type)
if typs = "VARCHAR" or typs = "BINARY" or typs = "CHAR" then
tbl_struct = tbl_struct & typs & "(" & rs(i).definedsize & ")"
else
tbl_struct = tbl_struct & typs & " "
end if
attrib = rs(i).attributes
if (attrib and adFldIsNullable) = 0 then
tbl_struct = tbl_struct&" NOT NULL"
end if
if rs(i).Properties("ISAUTOINCREMENT") = True then
tbl_struct = tbl_struct & " IDENTITY"
end if
tbl_struct = tbl_struct & "," & chr(10)
next
if primarykey <> "" then
tbl_struct = tbl_struct & "PRIMARY KEY ([" & primarykey & "]));"
else
len_of_sql = Len(tbl_struct)
tbl_struct = Mid(tbl_struct,1,len_of_sql-2)
tbl_struct = tbl_struct & ");"
end if
else
tbl_struct = "CREATE TABLE [" & table & "];"
end if
getsql = getsql & tbl_struct & chr(10) & chr(10)
end function

sub help()
echo "SQL 常用语句:<br><br>"
echo "创建表:<br>"
echo "CREATE TABLE [表名] (<br>"
echo "[test1] int not null identity,<br>"
echo "[test2] binary not null,<br>"
echo "primary key ([test1]))<br><br>"
echo "
  • 上一篇资讯: ASP中过滤UBB和Html标签
  • 下一篇资讯: Response.Flush的使用心得
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号