主题:一个asp Access升级到Sql的问题
<%@language=vbscript codepage=936 %>
<!--#include file="../conn/dbconn.asp"-->
<!--#include file="../inc/config.asp"-->
<!--#include file="Admin.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="../inc/ubbcode1.asp"-->
<!--#include file="inc/md5.asp"-->
<%
dim strFileName
const MaxPerPage=20
dim totalPut,CurrentPage,TotalPages
dim sql,rs,ID,LinkType
dim Action,FoundErr,ErrMsg
Action=trim(request("Action"))
ID=Trim(Request("ID"))
LinkType=trim(request("LinkType"))
strFileName="Admin_FriendLinks.asp?LinkType=" & LinkType
if request("page")<>"" then
currentPage=cint(request("page"))
else
currentPage=1
end if
if ID<>"" then
if Action="Check" then
conn.execute "Update FriendLinks set IsOK=1 where ID=" & CLng(ID)
elseif Action="CancelCheck" then
conn.execute "Update FriendLinks set IsOK=0 Where ID=" & CLng(ID)
elseif Action="Good" then
conn.execute "Update FriendLinks set IsGood=1 Where ID=" & CLng(ID)
elseif Action="CancelGood" then
conn.execute "Update FriendLinks set IsGood=0 Where ID=" & CLng(ID)
elseif Action="Del" then
conn.execute "Delete From FriendLinks Where ID=" & CLng(ID)
end if
end if
%>
<script LANGUAGE="javascript">
function Check() {
if (document.AddLink.SiteName.value=="")
{
alert("请输入网站名称!")
document.AddLink.SiteName.focus()
return false
}
if (document.AddLink.SiteUrl.value=="")
{
alert("请输入网站地址!")
document.AddLink.SiteUrl.focus()
return false
}
if (document.AddLink.SiteUrl.value=="http://")
{
alert("请输入网站地址!")
document.AddLink.SiteUrl.focus()
return false
}
if (document.AddLink.SiteAdmin.value=="")
{
alert("请输入站长姓名!")
document.AddLink.SiteAdmin.focus()
return false
}
if (document.AddLink.Email.value=="")
{
alert("请输入电子邮件地址!")
document.AddLink.Email.focus()
return false
}
if (document.AddLink.Email.value=="@")
{
alert("请输入电子邮件地址!")
document.AddLink.Email.focus()
return false
}
if (document.AddLink.SiteIntro.value=="")
{
alert("请输入网站简介!")
document.AddLink.SiteIntro.focus()
return false
}
}
function ConfirmDel()
{
if(confirm("确定要删除此友情链接站点吗?"))
return true;
else
return false;
}
</script>
<!-- #include file="Inc/Head.asp" -->
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#000000" Class="border">
<tr>
<td class="back_southidc" height="30" colspan=2 align=center><strong>友 情 链
接 管 理</strong></td>
</tr>
<tr bgcolor="#FFFFFF" class="tdbg">
<td width="77" height="30"><strong>管理导航:</strong></td>
<td width="512" height="30"><a href="Admin_FriendLinks.asp?Action=Add">添加友情链接</a> | <a href="Admin_FriendLinks.asp?LinkType=2">文字链接</a> | <a href="Admin_FriendLinks.asp?LinkType=1">LOGO链接</a> | <a href="Admin_FriendLinks.asp">所有链接</a></td>
</tr>
</table>
<br>
<%
if Action="Add" then
call Add()
elseif Action="SaveAdd" then
call SaveAdd()
elseif Action="Modify" then
call Modify()
elseif Action="SaveModify" then
call SaveModify()
else
call main()
end if
if FoundErr=True then
call WriteErrMsg()
end if
call CloseConn()
sub main()
sql="select * from FriendLinks "
if LinkType<>"" then
LinkType=CInt(LinkType)
if LinkType=1 then
sql=sql & " where LinkType=1 "
elseif LinkType=2 then
sql=sql & " where LinkType=2 "
end if
end if
sql=sql & "order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "目前共有 0 个友情链接"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"个站点"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"个站点"
else
currentPage=1
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"个站点"
end if
end if
end if
rs.close
set rs=nothing
end sub
sub showContent
dim i
i=0
%>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#000000" Class="border">
<tr bgcolor="#FFFFFF" class="title">
<td width="72" height="22" align="center">链接类型</td>
<td width="74" height="22" align="center">网站名称</td>
<td width="73" height="22" align="center">网站LOGO</td>
<td width="139" height="22" align="center">网站简介</td>
<td width="57" height="22" align="center">站长</td>
<td width="48" height="22" align="center">状态</td>
<td width="101" height="22" align="center">操作</td>
</tr>
<%
do while not rs.eof
%>
<tr bgcolor="#FFFFFF" class="tdbg" onMouseOver="this.style.backgroundColor='#BFDFFF'" onMouseOut="this.style.backgroundColor=''">
<td width="72" align="center">
<%
if rs("LinkType")=1 then
response.write "<a href='Admin_FriendLinks.asp?LinkType=1'>LOGO链接</a>"
else
response.write "<a href='Admin_FriendLinks.asp?LinkType=2'>文字链接</a>"
end if
%></td>
<td width="74"><a href="<%=rs("SiteUrl")%>" target='blank' title="<%=rs("SiteUrl")%>"><%=rs("SiteName")%></a></td>
<td width="73" align="center">
<%
if rs("LogoUrl")<>"" and rs("LogoUrl")<>"http://" then
if lcase(right(rs("LogoUrl"),3))="swf" then
Response.Write "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='88' height='31'><param name='movie' value='" & rs("LogoUrl") & "'><param name='quality' value='high'><embed src='" & rs("LogoUrl") & "' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='88' height='31'></embed></object>"
else
response.write "<a href='" & rs("SiteUrl") & "' target='_blank' title='" & rs("LogoUrl") & "'><img src='" & rs("LogoUrl") & "' width='88' height='31' border='0'></a>"
end if
else
response.write " "
end if
%> </td>
<td width="139"><%=rs("SiteIntro")%></td>
<td width="57" align="center"><a href="mailto:<%=rs("Email")%>"><%=rs("SiteAdmin")%></a></td>
<td width="48" align="center">
<%
if rs("IsOK")=True then
response.write "已审核"
else
response.write " "
end if
if rs("IsGood")=True then
response.write "<br>推荐"
end if
%> </td>
<td width="101" align="center">
<%
If rs("IsOK")=False Then
response.write "<a href='Admin_FriendLinks.asp?ID=" & rs("ID") & "&Action=Check'>审核通过</a> "
Else
response.write "<a href='Admin_FriendLinks.asp?ID=" & rs("ID") & "&Action=CancelCheck'>取消审核</a> "
End If
response.write "<a href='Admin_FriendLinks.asp?Action=Modify&ID=" & rs("ID") & "'>修改</a><br>"
if rs("IsGood")=False then
response.write "<a href='Admin_FriendLinks.asp?ID=" & rs("ID") & "&Action=Good'>设为推荐</a> "
Else
response.write "<a href='Admin_FriendLinks.asp?ID=" & rs("ID") & "&Action=CancelGood'>取消推荐</a> "
End If
response.write "<a href='Admin_FriendLinks.asp?Action=Del&ID=" & rs("ID") & "' onclick='return ConfirmDel();'>删除</a>"
%> </td>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</table>
<%
end sub
sub Add()
%>
<!--#include file="../conn/dbconn.asp"-->
<!--#include file="../inc/config.asp"-->
<!--#include file="Admin.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="../inc/ubbcode1.asp"-->
<!--#include file="inc/md5.asp"-->
<%
dim strFileName
const MaxPerPage=20
dim totalPut,CurrentPage,TotalPages
dim sql,rs,ID,LinkType
dim Action,FoundErr,ErrMsg
Action=trim(request("Action"))
ID=Trim(Request("ID"))
LinkType=trim(request("LinkType"))
strFileName="Admin_FriendLinks.asp?LinkType=" & LinkType
if request("page")<>"" then
currentPage=cint(request("page"))
else
currentPage=1
end if
if ID<>"" then
if Action="Check" then
conn.execute "Update FriendLinks set IsOK=1 where ID=" & CLng(ID)
elseif Action="CancelCheck" then
conn.execute "Update FriendLinks set IsOK=0 Where ID=" & CLng(ID)
elseif Action="Good" then
conn.execute "Update FriendLinks set IsGood=1 Where ID=" & CLng(ID)
elseif Action="CancelGood" then
conn.execute "Update FriendLinks set IsGood=0 Where ID=" & CLng(ID)
elseif Action="Del" then
conn.execute "Delete From FriendLinks Where ID=" & CLng(ID)
end if
end if
%>
<script LANGUAGE="javascript">
function Check() {
if (document.AddLink.SiteName.value=="")
{
alert("请输入网站名称!")
document.AddLink.SiteName.focus()
return false
}
if (document.AddLink.SiteUrl.value=="")
{
alert("请输入网站地址!")
document.AddLink.SiteUrl.focus()
return false
}
if (document.AddLink.SiteUrl.value=="http://")
{
alert("请输入网站地址!")
document.AddLink.SiteUrl.focus()
return false
}
if (document.AddLink.SiteAdmin.value=="")
{
alert("请输入站长姓名!")
document.AddLink.SiteAdmin.focus()
return false
}
if (document.AddLink.Email.value=="")
{
alert("请输入电子邮件地址!")
document.AddLink.Email.focus()
return false
}
if (document.AddLink.Email.value=="@")
{
alert("请输入电子邮件地址!")
document.AddLink.Email.focus()
return false
}
if (document.AddLink.SiteIntro.value=="")
{
alert("请输入网站简介!")
document.AddLink.SiteIntro.focus()
return false
}
}
function ConfirmDel()
{
if(confirm("确定要删除此友情链接站点吗?"))
return true;
else
return false;
}
</script>
<!-- #include file="Inc/Head.asp" -->
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#000000" Class="border">
<tr>
<td class="back_southidc" height="30" colspan=2 align=center><strong>友 情 链
接 管 理</strong></td>
</tr>
<tr bgcolor="#FFFFFF" class="tdbg">
<td width="77" height="30"><strong>管理导航:</strong></td>
<td width="512" height="30"><a href="Admin_FriendLinks.asp?Action=Add">添加友情链接</a> | <a href="Admin_FriendLinks.asp?LinkType=2">文字链接</a> | <a href="Admin_FriendLinks.asp?LinkType=1">LOGO链接</a> | <a href="Admin_FriendLinks.asp">所有链接</a></td>
</tr>
</table>
<br>
<%
if Action="Add" then
call Add()
elseif Action="SaveAdd" then
call SaveAdd()
elseif Action="Modify" then
call Modify()
elseif Action="SaveModify" then
call SaveModify()
else
call main()
end if
if FoundErr=True then
call WriteErrMsg()
end if
call CloseConn()
sub main()
sql="select * from FriendLinks "
if LinkType<>"" then
LinkType=CInt(LinkType)
if LinkType=1 then
sql=sql & " where LinkType=1 "
elseif LinkType=2 then
sql=sql & " where LinkType=2 "
end if
end if
sql=sql & "order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "目前共有 0 个友情链接"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"个站点"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"个站点"
else
currentPage=1
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"个站点"
end if
end if
end if
rs.close
set rs=nothing
end sub
sub showContent
dim i
i=0
%>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#000000" Class="border">
<tr bgcolor="#FFFFFF" class="title">
<td width="72" height="22" align="center">链接类型</td>
<td width="74" height="22" align="center">网站名称</td>
<td width="73" height="22" align="center">网站LOGO</td>
<td width="139" height="22" align="center">网站简介</td>
<td width="57" height="22" align="center">站长</td>
<td width="48" height="22" align="center">状态</td>
<td width="101" height="22" align="center">操作</td>
</tr>
<%
do while not rs.eof
%>
<tr bgcolor="#FFFFFF" class="tdbg" onMouseOver="this.style.backgroundColor='#BFDFFF'" onMouseOut="this.style.backgroundColor=''">
<td width="72" align="center">
<%
if rs("LinkType")=1 then
response.write "<a href='Admin_FriendLinks.asp?LinkType=1'>LOGO链接</a>"
else
response.write "<a href='Admin_FriendLinks.asp?LinkType=2'>文字链接</a>"
end if
%></td>
<td width="74"><a href="<%=rs("SiteUrl")%>" target='blank' title="<%=rs("SiteUrl")%>"><%=rs("SiteName")%></a></td>
<td width="73" align="center">
<%
if rs("LogoUrl")<>"" and rs("LogoUrl")<>"http://" then
if lcase(right(rs("LogoUrl"),3))="swf" then
Response.Write "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='88' height='31'><param name='movie' value='" & rs("LogoUrl") & "'><param name='quality' value='high'><embed src='" & rs("LogoUrl") & "' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='88' height='31'></embed></object>"
else
response.write "<a href='" & rs("SiteUrl") & "' target='_blank' title='" & rs("LogoUrl") & "'><img src='" & rs("LogoUrl") & "' width='88' height='31' border='0'></a>"
end if
else
response.write " "
end if
%> </td>
<td width="139"><%=rs("SiteIntro")%></td>
<td width="57" align="center"><a href="mailto:<%=rs("Email")%>"><%=rs("SiteAdmin")%></a></td>
<td width="48" align="center">
<%
if rs("IsOK")=True then
response.write "已审核"
else
response.write " "
end if
if rs("IsGood")=True then
response.write "<br>推荐"
end if
%> </td>
<td width="101" align="center">
<%
If rs("IsOK")=False Then
response.write "<a href='Admin_FriendLinks.asp?ID=" & rs("ID") & "&Action=Check'>审核通过</a> "
Else
response.write "<a href='Admin_FriendLinks.asp?ID=" & rs("ID") & "&Action=CancelCheck'>取消审核</a> "
End If
response.write "<a href='Admin_FriendLinks.asp?Action=Modify&ID=" & rs("ID") & "'>修改</a><br>"
if rs("IsGood")=False then
response.write "<a href='Admin_FriendLinks.asp?ID=" & rs("ID") & "&Action=Good'>设为推荐</a> "
Else
response.write "<a href='Admin_FriendLinks.asp?ID=" & rs("ID") & "&Action=CancelGood'>取消推荐</a> "
End If
response.write "<a href='Admin_FriendLinks.asp?Action=Del&ID=" & rs("ID") & "' onclick='return ConfirmDel();'>删除</a>"
%> </td>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</table>
<%
end sub
sub Add()
%>