<%

%>
<!--#include file="te_config.asp"-->
<%

	lConnID = request("cid")
	sTableName = request("tablename")
	sFieldName = request("fldname")
	
	OpenRS arrConn(lConnID)

	'Check if the user approved delete and has permissions to delete
	if (request("sure") <> "") and bFldDel then

		'Delete the indices if any
		set rs = conn.openSchema(adSchemaIndexes)
		do while not rs.eof
			if rs("table_name") = sTableName then
				if (rs("column_name") = sFieldName) then
					sSQL = "ALTER TABLE [" & sTableName & "] DROP CONSTRAINT [" & rs("index_name") & "]"
					conn.execute sSQL
				end if
			end if
			rs.movenext
		loop

		sSQL = "ALTER TABLE [" & sTableName & "] DROP COLUMN [" & sFieldName & "]"
		conn.execute sSQL
		
		response.redirect "te_tableedit.asp?cid=" & lConnID & "&tablename=" & sTableName
	end if

	'Check if the field is indexed
	set rs = conn.openSchema(adSchemaIndexes)
	do while not rs.eof
		if rs("table_name") = sTableName then
			if (rs("column_name") = sFieldName) then
				sErr = "Field '" & sFieldName & "' is indexed. If you delete this field, all related indices will also be deleted.<br><br>"
			end if
		end if
		rs.movenext
	loop
	
	CloseRS

%>
<!--#include file="te_header.asp"-->

<table border=0 cellspacing=1 cellpadding=2 bgcolor = "#ffe4b5" width=100%>
	<tr>
		<td class="smallertext">
			<a href="index.asp">管理首页</a> <a href="te_admin.asp">编辑页面</a> <a href="te_listtables.asp?cid=<%=request("cid")%>"><%=arrDesc(request("cid"))%></a> <a href="te_tableedit.asp?cid=<%=request("cid")%>&tablename=<%=server.urlencode(request("tablename"))%>">编辑表格 [<%=request("tablename")%>]</a> 删除区域
		</td>
		<td class="smallerheader" width=130 align=right>
		<%
		if bProtected then 
			response.write session("teFullName")
			response.write "<a href=""te_logout.asp""> (退出)</a>" 
		end if
		%>
		</td>
	</tr>
</table>

			<p class="smallerheader"><%=sErr%>你确信准备删除这些记录?</p>
			<a href="te_fieldremove.asp?<%=request.querystring%>&sure=1">是</a>&nbsp;
			<a href="<%=request.servervariables("http_referer")%>">否</a>
			
<!--#include file="te_footer.asp"-->
 

