<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p10")
'''''''''''''''''''''''''''''''''''''''''''''''
dim act,addsql
dim tablename,fieldname,fieldtype,sqlexe,charlen
act=request("act")
if(act="add") then
	tablename=trim(request.QueryString("tablename"))
	if(len(tablename)<1) then
 	response.Write("请指定正确的表名")
 	response.End()
	end if
	fieldname=trim(request.Form("fieldname"))
	if(len(fieldname)<1) then
 	response.Write("请指定正确的字段名")
 	response.End()
	end if
	fieldtype=trim(request.Form("fieldtype"))
	if(len(fieldtype)<1) then
 		response.Write("请指定正确的字段类型")
 		response.End()
	end if
	if fieldtype="varchar" then
		charlen=Cint(request.Form("varchar_len"))
		addsql="alter table "&tablename&" add "&fieldname&" "&fieldtype&" ("&charlen&") null"
	else
		addsql="alter table "&tablename&" add "&fieldname&" "&fieldtype
	end if
	conn.execute(addsql)
	response.Write("成功为表："&tablename&"添加字段："&fieldname)
end if
if(act="mod") then
	tablename=trim(request.QueryString("tablename"))
	if(len(tablename)<1) then
 	response.Write("请指定正确的表名")
 	response.End()
	end if
	fieldname=trim(request.Form("fieldname"))
	if(len(fieldname)<1) then
 	response.Write("请指定正确的字段名")
 	response.End()
	end if
	fieldtype=trim(request.Form("fieldtype"))
	if(len(fieldtype)<1) then
 	response.Write("请指定正确的字段类型")
 	response.End()
	end if
	if fieldtype="varchar" then
		charlen=Cint(request.Form("varchar_len"))
		addsql="alter table "&tablename&" ALTER COLUMN  "&fieldname&" "&fieldtype&" ("&charlen&") null"
	else
		addsql="alter table "&tablename&" ALTER COLUMN  "&fieldname&" "&fieldtype
	end if
	conn.execute(addsql)
	response.Write("成功为表："&tablename&"修改字段："&fieldname)
end if
if(act="dele") then
	
	tablename=trim(request.QueryString("tablename"))
	if(len(tablename)<1) then
 	response.Write("请指定正确的表名")
 	response.End()
	end if
	fieldname=trim(request.QueryString("fieldname"))
	if(len(fieldname)<1) then
 	response.Write("请指定正确的字段名")
 	response.End()
	end if
	conn.execute("ALTER TABLE "&tablename&" DROP COLUMN "&fieldname)
	response.Write("成功为表："&tablename&"删除字段："&fieldname)
end if
if(act="exe") then
	sqlexe=trim(request.Form("sqlexe"))
	if(len(sqlexe)<1) then
 	response.Write("请指定正确的字段名")
 	response.End()
	end if
	conn.execute(sqlexe)
end if
%>
<html>
<head>
<title>添加字段</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="refresh" content="1;URL=<%=request.ServerVariables("HTTP_REFERER")%>">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #D4D0C8;
}
.style1 {	color: #FFFFFF;
	font-weight: bold;
}
ul{ margin:0; text-align:left; list-style:none;}
li{ margin:0 5px 0 5px; float:left; list-style:none; list-style-type:none; padding:0;}
.tb{ float:left; margin:0; padding:0; text-align:center; width:80px;}
.tab{ widows:20px; margin:0; padding:0; float:left;}
-->
</style>
<link href="cs.css" rel="stylesheet" type="text/css">
</head>
<body>
<%

%>
</body>
</html>
<%
call connclose()
%>