if
if request("null") = "" then
sql = sql & " not null"
end if
if request("autoincrement") = "y" then
sql = sql & " identity"
end if
sql = trim(sql)
conn.execute(sql)
response.redirect "?key=view&table_name="& request("table_name")
end sub
''==================================================================添加字段函数
sub addfield()
on error resume next
fldname = request("fldname")
fldtype = request("field_type")
fldsize = request("fldsize")
fldnull = request("null")
fldautoincrement = request("autoincrement")
table_name = request("table_name")
if fldname <> "" and fldtype <> "" then
sql = "alter table [" & table_name & "] add ["&fldname&"] " & fldtype
if fldsize <> "" then
sql = sql & "(" & fldsize & ")"
end if
if fldnull <> "ON" then
sql = sql & " not null"
end if
if fldautoincrement = "ON" then
sql = sql & " identity"
end if
conn.execute(sql)
response.redirect "?key=view&table_name=" & table_name
else
echo "输入数据错误!<input type=''button'' name=''ok'' value='' 返 回 '' onClick=''javascript:history.go(-1)''>"
end if
if err <> 0 then
echo err.description
echo "<input type=''button'' name=''ok'' value='' 返 回 '' onClick=''javascript:history.go(-1)''>"
response.end
end if
end sub
''==================================================================编辑数据
sub editdata()
dim keys,names,values,action,rs,sql,tab
on error resume next
keys = request("primarykey")
names = request("table_name")
values = request("primarykeyvalue")
action = request("action")
Set rs = Server.CreateObject("Adodb.RecordSet")
if action = "" or action = "save" or action = "new" then
sql = "select * from " & names & " where " & keys & " = " & values
end if
if action = "pre" then
sql = "select top 1 * from " & names & " where " & keys & " < " & values & " order by " & keys & " desc"
end if
if action = "next" then
sql = "select top 1 * from " & names & " where " & keys & " > " & values & " order by " & keys & " asc"
end if
if action = "add" then
sql = "Select * From [" & names & "]"
end if
rs.Open sql, conn, 1, 3
if rs.eof and action = "new" then
sql = "Select * From [" & names & "]"
rs.Open sql, conn, 1, 3
end if
if action = "save" or action = "new" then
If action = "new" Then rs.AddNew
For Each tab In rs.Fields
If Keys <> tab.Name Then
rs(tab.Name) = Request.Form(tab.Name & "_Column")
if err <> 0 then
echo tab.name & err.description
echo "<input type=''button'' name=''ok'' value='' 返 回 '' onClick=''javascript:history.go(-1)''>"
respon