⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_sql.asp

📁 本程序采用花香内核
💻 ASP
字号:
<%Admin="SQL"%>
<!--#include file="check.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="mdb.asp"-->
<%
dim founderr,errmsg
founderr=false
errmsg=""
if session("adminlogin")<>sessionvar then
  founderr=true
  errmsg=errmsg+"<br>"+"<li>你尚未登录,或者超时了!请<a href='admin.asp'>重新登录</a>!"
  call diserror()
  response.end
else
	call main()
	footer()
end if
Sub main()
	Dim SQL_Statement,RecordsAffected,RetRs,oField,Page_Count,TotalRec,i,abgcolor,CurPage,PCount,EndPage
%>
<HTML><HEAD><TITLE>数据库SQL操作</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="inc/admin.css" type=text/css rel=StyleSheet>
<META content="MSHTML 6.00.2800.1126" name=GENERATOR>
</HEAD>
<body >
<%
Response.Write "<table width='95%' border='0' cellspacing='1' cellpadding='3' align=center class=lanyubk style='border-collapse: collapse'><tr class=lanyuss><td colspan=2>*数据库SQL操作</td></tr><tr class=lanyuds><td align=right Width=200><b>SQL语句执行操作:</b></td><td><blockquote><br>*****本操作仅限高级、对SQL编程比较熟悉的用户,您可以直接输入SQL执行语句,比如select * from friendlink,查询友情链接信息。<br><font color=#ff0000>在操作前请慎重考虑您的执行语句是否正确和完整,执行后不可恢复。</Font></blockquote></td></tr>"
	If Request("action") = "sql_done" Then
		SQL_Statement=Request("SQL_Statement")
		If SQL_Statement<>"" then
			On Error Resume Next
			Server.ScriptTimeOut=999999
			Set RetRs=Conn.Execute(SQL_Statement,RecordsAffected)
			If Err.number="0" then
				On Error Goto 0
				Response.write "<tr  class=lanyuds><th colspan=2><b>执行结果</b></th></tr><tr  class=lanyuds><td align=center colspan=2>"
				If RetRs.State=0 Then
					If RecordsAffected>0 Then
						Response.write "执行成功,共有 "&RecordsAffected&" 条记录被处理。<br><br>[ <a href=# onclick=history.go(-1)>返回上一页</a> ]</td></tr></Table>"
					Else
						Response.write "执行成功,没有任何记录被处理。<br><br>[ <a href=# onclick=history.go(-1)>返回上一页</a> ]</td></tr></Table>"
					End If
				Else
					RetRs.Close
					RetRs.Open SQL_Statement,Conn,1,1
					If RetRs.Bof And RetRs.Eof Then
						Response.write "执行成功,没有任何记录被返回。<br><br>[ <a href=# onclick=history.go(-1)>返回上一页</a> ]</td></tr></Table>"
					Else
						CurPage=request("page")
						If CurPage="" or not IsNumeric(CurPage) Then
							CurPage=1
						Else
							CurPage=CLng(CurPage)
						End If
						'删除语句
						If RetRs.RecordCount>0 Then
							RetRs.AbsolutePage=CurPage
							Page_Count=0
							TotalRec=RetRs.RecordCount
							Response.write "执行成功,共返回 "&TotalRec&" 条记录。<br><br>[ <a href=# onclick=history.go(-1)>返回上一页</a> ]</td></tr></Table>"
							Response.Write "<br><table width=95% border='1' cellspacing='1' cellpadding='3' align=center class=lanyubk style='border-collapse: collapse'><tr  class=lanyuds>"
							For Each oField In RetRs.Fields
								Response.Write "<Th>" & oField.Name &"</Th>"
							Next
							Do While (not RetRs.eof) And (not Page_Count = Cint(RetRs.PageSize))
								Response.Write "<tr  class=lanyuds>"
								If Page_Count mod 2 = 0 Then
									abgcolor="ForumRow"
								Else
									abgcolor="ForumRowHilight"
								End If
								For i=0 To RetRs.Fields.Count-1
									Response.write "<td class="&abgcolor&">"
									If IsNull(RetRs(i)) Then
										Response.Write ""
									Else
										Response.Write Server.HTMLEncode(RetRs(i))
									End If
									Response.write "</td>"
								Next
								Response.Write "</tr>"
								Page_count = Page_Count + 1
								RetRs.MoveNext
							Loop
							Response.Write "<tr  class=lanyuds><td colspan="&RetRs.Fields.Count&" class=forumrow align=align>分页:"
							Pcount=RetRs.PageCount
							If CurPage > 4 Then
								Response.write "<a href=""?page=1&action=sql_done&sql_statement="&SQL_Statement&""">[1]</a> ..."
							End If
							If PCount>CurPage+3 Then
								EndPage=CurPage+3
							Else
								EndPage=PCount
							End If
							For i=CurPage-3 To EndPage
								If i>=1 Then
									If i = CLng(CurPage) Then
										Response.write " <font color=red>["&i&"]</font>"
									Else
										Response.write " <a href=""?page="&i&"&action=sql_done&sql_statement="&SQL_Statement&""">["&i&"]</a>"
									End If
								End If
							Next
							If CurPage+3 < PCount Then 
								Response.write "... <a href=""?page="&PCount&"&action=sql_done&sql_statement="&SQL_Statement&""">["&PCount&"]</a>"
							End If
						Else
							Response.write "执行成功,返回如下记录:<br><br>[ <a href=# onclick=history.go(-1)>返回上一页</a> ]</td></tr></Table>"
							Response.Write "<br><table width=95% border='0' cellspacing='1' cellpadding='3' align=center Class=TableBorder><tr  class=lanyuds>"
							For Each oField In RetRs.Fields
								If oField.Name<>"" Then
									Response.Write "<Th>" & oField.Name &"</Th>"
								Else
									Response.Write "<Th>执行结果:</Th>"
								End If
							Next
							Do While not RetRs.eof
								Response.Write "<tr  class=lanyuds>"
								If Page_Count mod 2 = 0 Then
									abgcolor="ForumRow"
								Else
									abgcolor="ForumRowHilight"
								End If
								For i=0 To RetRs.Fields.Count-1
									Response.write "<td class="&abgcolor&">"
									If IsNull(RetRs(i)) Then
										Response.Write ""
									Else
										Response.Write RetRs(i)
									End If
									Response.write "</td>"
								Next
								Response.Write "</tr>"
								RetRs.MoveNext
							Loop
						End If
						Response.Write "</table></td></tr></Table>"
					End If
					RetRs.Close
				End If
			Else
				Response.write "<tr  class=lanyuds><th colspan=2><b>执行结果</b></th></tr><tr  class=lanyuds><td align=center colspan=2>SQL语句有问题,具体错误信息如下:<br>"&Err.Description&"<br><br>[ <a href=# onclick=history.go(-1)>返回上一页</a> ]</td></tr></Table>"
				Err.clear
			End if
			On Error Goto 0
			Set RetRs=Nothing
		End If
	Else
		Response.Write "<tr  class=lanyuds><th colspan=2><b></b>请输入SQL语句</th></tr><Form Name=SQLForm Method=Post Action='?action=sql_done'><tr  class=lanyuds><td align=center colspan=2><FieldSet><Legend>请输入SQL语句</Legend>指令:<Input type='text' name='SQL_Statement' Size=60><br><Input type='Submit' Value=' 执  行 '></FieldSet></td></tr></Form></Table>"
	End If
End Sub
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -