创建表:<%=table_name%>
<% end sub '==================================================================构建创建表的SQL语句 sub create_table() dim sql,i,primarykey on error resume next sql = "CREATE TABLE ["&request("table_name")&"] (" for i = 1 to request("i") sql = sql & "[" & request("field_name")(i) & "] " & request("field_type")(i) if request("field_size")(i) <> "" then sql = sql & "(" & request("field_size")(i) & ")" end if if request("null")(i) = "NOT_NULL" then sql = sql & " not null" end if if request("autoincrement")(i) = "自动编号" then sql = sql & " identity" end if if request("primarykey")(i) = "primarykey" then primarykey = request("field_name")(i) end if 'if primarykey <> "" then sql = sql & "," 'end if next if primarykey<>"" then sql=sql&" primary key (["&primarykey&"]) " end if sql = sql & ")" sql = replace(sql,"()","") '构建空表 response.redirect "?key=sql&sql=" & sql end sub '==================================================================修改表名或字段名 2006-09-08 sub reobj() on error resume next Dim mydb,mytable,tablename tablename = request("tablename") Set mydb = Server.CreateObject("ADOX.Catalog") mydb.ActiveConnection = conn if request("obj") = "field" then '修改字段名 dim fieldsname,newfieldsname fieldsname = request("fieldsname") newfieldsname = request("newfieldsname") Set mytable = Server.CreateObject("ADOX.Table") Set mytable = mydb.Tables(tablename) mytable.Columns(fieldsname).Name = newfieldsname end if if request("obj") = "table" then '修改表名 dim newtablename newtablename = request("newtablename") mydb.Tables(tablename).Name = newtablename end if if err <> 0 then echo err.description echo "" exit sub end if if request("obj") = "field" then response.Redirect "?key=view&table_name=" & tablename else response.Redirect "?key=view&table_name=" & newtablename end if end sub sub dbope if session("dbope") <> 1 then %> <% session("dbope")=1 end if end sub '==================================================================查看表结构函数 sub view(table_name) 'table_name = 表名称 dim rs,sql,table,primary,primarykey,i,editstr,typs on error resume next table = table_name 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 %> 表:<%=table_name%>字 段 名 | 类 型 | 设定大小 | 允许空 | 自动编号 | 主键 | 执行操作 |
<%=rs(i).name%> | <%=typ(rs(i).type)%> | <%=rs(i).definedsize%> | <%=iif((rs(i).Attributes and adFldIsNullable)=0,"No","Yes")%> | <%=iif(rs(i).Properties("ISAUTOINCREMENT") = True,"是","否")%> | <%=iif(rs(i).name = primarykey,"是","否")%> | 修改 删除 |
" echo " |
当前表:<%=request("table_name")%> &primarykey=<%=request("primarykey")%>&action=add">插入新记录 | <% end if %><% echo "共有" & rs.recordCount & "条纪录 当前" & page & "/" & rs.PageCount & "页" if page > 1 then echo "首页 " echo "上页 " end if if (rs.PageCount > 1 and page < rs.PageCount) then echo "下页 " echo "末页 " end if echo "转到:第" echo "页" %> |
操作 | 删 | " end if for i = 0 to rs.fields.count - 1 '循环字段名 set field = rs.fields.item(i) echo "" & field.name & " | " next echo "|
编辑 | " echo "× | " end if for i = 0 to rs.fields.count - 1 set field = rs.fields.item(i) if len(field.value) < 12 then echo "" & field.value & " | " else echo "" & field.value & " | " end if next echo "
" & field.name & " | " next echo "
" & field.value & " | " next echo "
表: 主界面 退出 Help
<% set objSchema = Conn.OpenSchema(adSchemaTables) Do While Not objSchema.EOF if objSchema("TABLE_TYPE") = "TABLE" then '输出表名 echo "" & objSchema("TABLE_NAME") & " " end if objSchema.MoveNext Loop echo "所有视图: " objSchema.MoveFirst Do While Not objSchema.EOF if objSchema("TABLE_TYPE") = "VIEW" then '输出表名 echo "" & objSchema("TABLE_NAME") & " " end if objSchema.MoveNext Loop objSchema.Close set objSchema = nothing 'echo "存储过程: " 'set objSchema = Conn.OpenSchema(adSchemaProcedures) 'Do While Not objSchema.EOF ' echo "" & objSchema("PROCEDURE_NAME") & " " 'objSchema.MoveNext 'Loop 'objSchema.Close 'set objSchema = nothing %> |
<%
select case request("key")
case "" '显示主界面
call main("")
case "addtable" '显示创建表界面
call add_table(request("table_name"),request("field_num"))
case "createtable" '执行创建表
call create_table()
case "view"
call view(request("table_name"))
case "sql"
call main("1")
call exesql(trim(request("sql")))
case "addfield"
call addfield()
case "editfidlevi"
call view(request("table_name"))
case "editfidle"
call editfidle()
case "exit"
session("dbtype") = ""
session("dbstr") = ""
session("db007pass") = ""
response.redirect "?"
case "tosql"
call tosql(request("strt"))
case "proc"
call main("1")
call showproc()
case "help"
call help()
case "edit"
call EditData()
case "reobj"
call reobj()
end select
%>
|