(request.form("SchemaTable")) <> "" then Call showSchema (adSchemaTables)
if trim (request.form("SchemaColumn")) <> "" then Call showSchema(adSchemaColumns)
if trim (request.form("SchemaProvider")) <> "" then Call showSchema(adSchemaProviderTypes)
sql = trim(request("sql"))
if sql = "" then exit sub
sql = RegExpReplace(sql, "(--)(.)*\n", "") ''替换注释
sql = RegExpReplace(sql, "\n[\s| ]*\r", "") ''替换空行
sql = RegExpReplace(sql, "\n", "") ''替换换行符
sql = RegExpReplace(sql, "\r", "") ''替换回车符
if (LCase(left(sql,len("select"))) = "select") and instr(sql,"into") = 0 then
Call showSelect (sql)
if err <> 0 then echo "<br><font color=red>" & err.description & "</font>"
response.end
else
''如果非select语句,允许执行多条以分号分隔的语句
dim aSql,iLoop
aSql = split(sql,";")
for iLoop = 0 to UBound(aSql)
if trim(aSql(iLoop)) <> "" then
conn.execute (aSql(iLoop))
if err <> 0 then
echo "<br><font color=red>" & err.description & "<br> <b>"
echo iLoop + 1 & "、</b></font><font color=#CC6600>" & aSql(iLoop) & "</font><br>"
''err.clear() ''忽略错误
exit sub ''中止执行
else
echo "<div style=''padding:3px 0px;border-bottom:1px solid #069;''><b>" & iLoop + 1 & "、</b>" & aSql(iLoop) & "</div>"
end if
end if
next
echo "<font color=red><h4>命令执行成功</h4></font>"
end if
end sub
''显示数据库信息
''QueryType有以下三个主要参数
''adSchemaTables
''adSchemaColumns
''adSchemaProviderTypes
''Call showSchema (adSchemaTables)
sub showSchema(QueryType)
dim rs
''set rs = conn.OpenSchema()
set rs = conn.OpenSchema (QueryType)
''set rs = conn.OpenSchema (adSchemaProviderTypes)
echo "<div style=''overflow-x:auto;overflow-y:auto; width:800;height:380;''><table border=0 border=0 cellpadding=3 cellspacing=1 bgcolor=#CCCCCC><tr>"
for i = 0 to rs.fields.count - 1 ''循环字段名
set field = rs.fields.item(i)
echo "<td bgcolor=''#FFFFFF''>" & field.name & " </td>"
next
echo "</tr>"
dim i,field
do while not rs.eof ''循环数据
echo "<tr>"
for i = 0 to rs.fields.count - 1
set field = rs.fields.item(i)
echo "<td bgcolor=''#FFFFFF''>" & field.value & " </td>"
next
echo "</tr>"
rs.MoveNext
loop
echo "</table></div>"
end sub
%>
<%
''==================================================================导出SQL
sub tosql(strt)
''strt = 0 导出结构
''strt = 1 导出内容
dim strsql
if strt = "0"