📄 admin_sql.asp
字号:
<!--#include file="admin_conn.asp"-->
<!--#include file="../include/admin_setting.asp"-->
<!--#include file="admin_function.asp"-->
<%
'=========================================================
'程序名称:茂盛网站管理系统(MSCSM)
'当前版本:Maosin CMS Version 1.0 Powered by maosin.com
'程序作者:阿茂(李胜茂)
'网站地址:www.maosin.com www.maosin.net
' QQ:57861417
'电子邮箱:maosin@163.com
'---------------------------------------------------------
'Copyright (C) 2006 maosin.com All Rights Reserved.
'=========================================================
Call admin_top()
if getPopedom("dataSQL")=false then
popedomMsg
else
%>
<table width="100%" border="0" cellpadding="6" cellspacing="1" class="text table_border mainTable">
<tr>
<td height="31" align="center" valign="middle" class="td_titleT">SQL语句操作说明</td>
</tr>
<tr class="td_bgcolor">
<td valign="top">
<span style="line-height:20px;">使用注意:<br>
1、本操作仅限高级、对SQL编程比较熟悉的用户!<br>
常用示示例说明<br>
1、数据记录筛选:select * from 数据表 [ where 字段名=字段值 order by 字段名 ]<br>
2、更新数据记录:update 数据表 set 字段名1=字段值1,……字段名n=字段值n [where 条件表达式]<br>
3、删除数据记录:delete from 数据表 [where 条件表达式]<br>
4、添加数据记录:insert into 数据表 (字段1,字段2,字段3……) value (值1,值2,值3……) <br>
5、其它更高级的用法请参考SQL相关书籍</span>
</td>
</tr>
</table>
<%table(5)
Select Case LCase(Request.QueryString("action"))
Case LCase("sqlQuery")
Call sqlQuery()
Case Else
Call sqlin()
End Select
end if
Sub sqlin()
%>
<table width="100%" border="0" cellpadding="6" cellspacing="1" class="text table_border mainTable">
<tr>
<td width="100%" height="24" align="center" valign="middle" class="td_titleT">请输入SQL语句</td>
</tr>
<form action="?action=sqlquery" name="sqlform" method="post" onkeydown="if(event.keyCode==13 && event.ctrKey)sqlform.submit()">
<tr class="td_bgcolor">
<td height="81" align="center" valign="middle"> <textarea name="sql" cols="110" rows="5" wrap="VIRTUAL" id="sqlexecute"></textarea>
</tr>
<tr class="td_bgcolor">
<td height="33" align="center" valign="middle"> <input type="submit" name="execute" value="开始执行"></td></tr>
</form>
</table>
<%End Sub
'=======================================================
Sub sqlQuery()%>
<table width="100%" border="0" cellpadding="6" cellspacing="1" class="text table_border mainTable">
<tr>
<td width="100%" height="24" align="center" valign="middle" class="td_titleT">SQL语句执行结果</td>
</tr>
<tr>
<td height="100" align="center" valign="middle" class="td_bgcolor">
<%
Dim sql,executeCount,table_temp,nextpage
sql=request("sql")
if sql<>"" then
on error resume next
Server.ScriptTimeOut=999999
set rs=conn.execute(sql,executeCount)
if err.Number=0 then
if rs.state=0 then
if executeCount>0 then
Response.Write("SQL语句执行成功!<br><br>共处理<font color='#ff0000'>"&executeCount&"</font>条记录!<br><p>[<a href='#' onclick='window.history.go(-1);'>点击返回</a>]</p>")
else
Response.Write("SQL语句执行成功!<br><br>没有记录被处理!<br><p>[<a href='#' onclick='window.history.go(-1);'>点击返回</a>]</p>")
end if
else
rs.close
rs.open sql,conn,1,1
if (not rs.eof) and (not rs.bof) then
Response.Write("SQL语句执行成功!共返回<font color='#ff0000'>"&rs.RecordCount&"</font>条记录结果<br><p>[<a href='#' onclick='window.history.go(-1);'>点击返回</a>]</p>")
rs.PageSize=20
pgCount=rs.pageCount
rscount=rs.RecordCount
colnum=rs.fields.count
if request.QueryString("page")="" then
rs.absolutePage=1
else
rs.absolutePage=request.QueryString("page")
end if
nextpage="分<font color='#ff0000'>"&rs.absolutepage&"</font>/<font color='#ff0000'>"&pgcount&"</font>页 "
if rs.absolutepage>1 then
nextpage=nextpage&"<a href='?action=sqlquery&sql="&sql&"&page=1'>首页</a> "
else
nextpage=nextpage&"首页 "
end if
if rs.absolutepage<>1 then
nextpage=nextpage&"<a href='?action=sqlquery&sql="&sql&"&page="&rs.absolutepage-1&"'>上一页</a> "
end if
if (pgcount - rs.absolutepage)<9 then
pagecountsize=(pgcount-rs.absolutepage)+rs.absolutepage
else
pagecountsize=rs.absolutepage+9
end if
for i=rs.absolutepage to pagecountsize
nextpage=nextpage&"<a href='?action=sqlquery&sql="&sql&"&page="&i&"'><font color='#ff0000'>"&i&"</font></a> "
next
if rs.absolutepage<pgcount then
nextpage=nextpage&" <a href='?action=sqlquery&sql="&sql&"&page="&pgcount&"'>尾页</a> "
else
nextpage=nextpage&" 尾页"
end if
dim num,fdvalue,line
table_temp="<table width='100%' border='0' cellpadding='4' cellspacing='1' class='text table_border mainTable'><tr class='td_titleT'>"
for num=0 to rs.fields.count-1
table_temp=table_temp&"<td>"&rs.fields(num).name&"</td>"
str=str&rs.fields(num).name
next
table_temp=table_temp&"</tr>"
line=1
do while not rs.eof and line<=rs.PageSize
table_temp=table_temp&"<tr class=""td_bgcolor"" onmouseover=""mouseOver(this)"" onmouseout=""mouseOut(this)"">"
for num=0 to rs.fields.count-1
fdvalue=rs.fields(num).value
if isnull(fdvalue) then
table_temp=table_temp&"<td> </td>"
elseif not isNumeric(fdvalue) then
table_temp=table_temp&"<td>"&server.HTMLEncode(fdvalue)&"</td>"
else
table_temp=table_temp&"<td>"&fdvalue&"</td>"
end if
next
table_temp=table_temp&"</tr>"
rs.MoveNext
line=line+1
loop
table_temp=table_temp&"<tr class=""td_titleB""><td colspan='"&colnum&"'>"&nextpage&"</td></tr></table>"
else
Response.Write("SQL语句执行成功!<br><br>没有记录返回!<br><p>[<a href='#' onclick='window.history.go(-1);'>点击返回</a>]</p>")
end if
rs.close
end if
else
Response.Write("SQL语句执行时发生如下的错误:<br><br>"&err.Description&"<br><p>[<a href='#' onclick='window.history.go(-1)'>点击返回</a>]</p>")
end if
err.clear
end if
%>
</td></tr></table
>
<%
Call table(8)
Response.Write(table_temp)'输出结果
End Sub
'========================================================
'MaoSin CMS 1.1 Power by maosin.com
'Email: maosin@163.com , maosin@maosin.com
'Web: http://www.maosin.com http://www.maosin.net
'Copyright (C) 2006 maosin.com All Rights Reserved.
'========================================================
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -