📄 admin_db_executesql.asp
字号:
<!--#include file=admin_login_check.asp-->
<br>
<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="20">直接执SQL语句<br>
<%
call showsqlinput
if Request.QueryString("action")="exe" Then
Dim strsql
strsql=Request.form("sql")
if Request.form("rs")<>"" and strsql<>"" then
executesql strsql,1
elseif Request.Form("nors")<>"" and strsql<>"" then
executesql strsql,2
end if
end if
%>
<p></p></td>
</tr>
</table>
<%sub showsqlinput
%>
<table width=96% align="center">
<tr>
<td><form name="form1" method="post" action="admin_db_executesql.asp?action=exe">
<p> 注意:待执行SQL语句(警告:执行语句要<font color="#FF0000">万分小心</font>!) <br>
执行SQL语句有两个选项,如果要求得到记录集,请点击第一个提交按钮,否则请选第二个<br>
<br>
<textarea name="sql" cols="80" rows="7"><%=Request.form("sql")%></textarea>
</p>
<p>
<input type="submit" name="rs" value="得到记录集">
<input type="submit" name="nors" value="不要记录集">
</p>
</form>
<br> </td>
</tr>
</table>
<%
end sub
function executesql(sql,sqltype)
'on error resume next
dim rs,i
set conn = Server.CreateObject("ADODB.Connection")
connc = "provider=microsoft.jet.oledb.4.0;" & "data source = " & server.mappath("../"&const_AccessDatabase&"")
conn.open connc
conn.Errors.Clear
Response.write "<font color=red>SQL语句:"&sql&"</font><br>"
if sqltype=1 then
set rs=conn.Execute (sql)
if not rs.eof then
%>
<table border=1 cellspacing=0 cellpadding=0 width=600 align=center>
<tr>
<% For i=0 to Rs.Fields.Count-1%>
<th><%=Rs(i).Name%></th>
<%next%>
</tr>
<% While not Rs.Eof%>
<tr>
<% For i=0 to Rs.fields.count-1%>
<td><%=Rs(i)%></td>
<%Next%>
</tr>
<%
Rs.movenext
Wend
rs.close
end if
elseif sqltype=2 then
conn.execute (sql)
end if
end function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -