学校网站管理系统
源代码在线查看: admin_sql.asp
if session("superlogin")yecao then
response.Write "alert('您还没有登陆!');this.location.href='index.asp';"
Response.End
elseif session("superadmin")"admin" then
response.Write "alert('您不是超级管理员!您的权限不足!');this.location.href='index.asp';"
Response.End
end if
Dim SQL_Statement,RecordsAffected,RetRs,oField,Page_Count,TotalRec,i,abgcolor,CurPage,PCount,EndPage%>
SQL语句执行操作说明!
本操作仅限高级、对SQL编程比较熟悉的用户!
您可以直接输入SQL执行语句,比如〖 select * from YC_link 〗查询友情链接信息。
数据记录筛选:select * from 数据表 [ where 字段名=字段值 order by 字段名 ]
更新数据记录:update 数据表 set 字段名1=字段值1,……字段名n=字段值n [where 条件表达式]
删除数据记录:delete from 数据表 [where 条件表达式]
添加数据记录:insert into 数据表 (字段1,字段2,字段3……) value (值1,值2,值3……)
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 " SQL语句执行结果"
If RetRs.State=0 Then
If RecordsAffected>0 Then
Response.write "执行成功,共有 "&RecordsAffected&" 条记录被处理。[ 返回上一页 ]"
Else
Response.write "执行成功,没有任何记录被处理。[ 返回上一页 ]"
End If
Else
RetRs.Close
RetRs.Open SQL_Statement,Conn,1,1
If RetRs.Bof And RetRs.Eof Then
Response.write "执行成功,没有任何记录被返回。[ 返回上一页 ]"
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&" 条记录。[ 返回上一页 ]"
Response.Write ""
For Each oField In RetRs.Fields
Response.Write "" & oField.Name &""
Next
Do While (not RetRs.eof) And (not Page_Count = Cint(RetRs.PageSize))
Response.Write ""
If Page_Count mod 2 = 0 Then
abgcolor="ForumRow"
Else
abgcolor="ForumRowHilight"
End If
For i=0 To RetRs.Fields.Count-1
Response.write ""
If IsNull(RetRs(i)) Then
Response.Write ""
Else
Response.Write Server.HTMLEncode(RetRs(i))
End If
Response.write ""
Next
Response.Write ""
Page_count = Page_Count + 1
RetRs.MoveNext
Loop
Response.Write "分页:"
Pcount=RetRs.PageCount
If CurPage > 4 Then
Response.write "[1] ..."
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 " ["&i&"]"
Else
Response.write " ["&i&"]"
End If
End If
Next
If CurPage+3 < PCount Then
Response.write "... ["&PCount&"]"
End If
Else
Response.write "执行成功,返回如下记录:[ 返回上一页 ]"
Response.Write ""
For Each oField In RetRs.Fields
If oField.Name"" Then
Response.Write "" & oField.Name &""
Else
Response.Write "执行结果:"
End If
Next
Do While not RetRs.eof
Response.Write ""
If Page_Count mod 2 = 0 Then
abgcolor="ForumRow"
Else
abgcolor="ForumRowHilight"
End If
For i=0 To RetRs.Fields.Count-1
Response.write ""
If IsNull(RetRs(i)) Then
Response.Write ""
Else
Response.Write RetRs(i)
End If
Response.write ""
Next
Response.Write ""
RetRs.MoveNext
Loop
End If
Response.Write ""
End If
RetRs.Close
End If
Else
Response.write "执行结果SQL语句有问题,具体错误信息如下:"&Err.Description&"[ 返回上一页 ]"
Err.clear
End if
On Error Goto 0
Set RetRs=Nothing
End If
Else
%>
function sql()
if(document.SQLForm.SQL_Statement.value=="")
{alert("操作语句不能为空!");
document.SQLForm.SQL_Statement.focus();
return false;}}
return true;}
请输入SQL语句!
Copyright©2006-2008 WEB300源码中心 2006