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

📄 asp1.txt

📁 asp代码
💻 TXT
字号:
conn.asp 
<% 
dim conn,mdbfile 
mdbfile=server.mappath("db1.mdb") 
set conn=server.createobject("adodb.connection") 
conn.open "driver={microsoft access driver (*.mdb)};dbq="&mdbfile 
%> 


添加数据页 
Add.asp 

<form name="form1" method="post" action="Save.asp"> 
<p> 
<input name="xingming" type="text" id="xingming"> 
</p> 
<p> 
<input name="xingbie" type="text" id="xingbie"> 
</p><input name="" type="submit" value="提交"> 
<input type="reset" name="Submit" value="重置"> 
</form> 

保存数据页 
Save.asp 
<!--#include file="Conn.asp"--> 
<% 
xingming = Request("xingming") 
xingbie = Request("xingbie") 


Set iRs = Server.CreateObject("ADODB.RecordSet") 
iSQL = "Select * from Data Where (Id is null)" 
iRs.Open iSQL,Conn,1,3 
iRs.AddNew 
iRs("xingming") = xingming 
iRs("xingbie") = xingbie 
iRs.Update 
iRs.Close() 
Set iRs = Nothing 
Conn.Close() 
Set Conn = Nothing 

Response.Write("<script>alert('添加数据成功');location.href='Add.asp';</script>") 
%> 

罗列页 
List.asp 
<!--#include file="Conn.asp"--> 
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> 
<% 
Set oRs = Server.CreateObject("ADODB.RecordSet") 
iSQL = " Select * from Data Order By Id Desc" 
oRs.Open iSQL,Conn,1,1 
if oRs.eof and oRs.bof then 
Response.Write("<tr><td height=""120"" align=""center"" bgcolor=""#FFFFFF""><font color=""red"">还没有记录...</font></td></tr>") 
Response.end 
else 
%> 
<tr> 
<td height="22" colspan="4" align="center">姓名</td> 
<td align="center">性别</td> 
<td width="25%" align="center">选择操作</td> 
<td width="9%" align="center">是否删除</td> 
</tr> 
<% 
oRs.pagesize=15 
nPageCount=oRs.PageCount 
if CurrentPage>oRs.PageCount then CurrentPage=oRs.PageCount 
if CurrentPage<=0 then CurrentPage=1 
oRs.absolutepage=CurrentPage 

for i = 1 to oRs.pagesize 
%> 
<tr> 
<td height="26" colspan="4" align="center" bgcolor="#FFFFFF"><%=oRs("xingming")%></td> 
<td align="center" bgcolor="#FFFFFF"><%=oRs("xingbie")%></td> 
<td align="center" bgcolor="#FFFFFF"> <a href="Edit.asp?Id=<%=oRs("Id")%>">编辑</a></td> 
<td align="center" bgcolor="#FFFFFF"><a href="Del.asp?Id=<%=oRs("Id")%>" onclick="return DelConfirm();">删除</a></td> 
</tr> 
<% 
oRs.MoveNext 
if oRs.eof then Exit for 
Next 
end if 
%> 
<tr> 
<td height="26" colspan="7" align="center" bgcolor="#FFFFFF"><table width="87%" height="23" border="0" cellpadding="0" cellspacing="0"> 
<tr> 
<td align="right"><%PageLink()%></td> 
</tr> 
</table></td> 
</tr> 
<td width="3%"></form> 
</table> 
<% 
Sub PageLink() 
Dim PageName 
PageName = Request.ServerVariables("SCRIPT_NAME") 
Response.Write "共 <font color=""red""><b>" & oRs.RecordCount & "</b></font> 个用户    " 
Response.Write "<font color=""red"">" & CurrentPage & "</font>/" & nPageCount & " 页   " 
if Keyword="" then 
If CurrentPage = 1 Or nPageCount=0 Then 
Response.Write "<font color=""#CCCCCC"">首页</font> " 
Else 
Response.Write "<a href=""" & PageName & "?Page=1&Use_Type=" & Use_Type & """>首页</a> " 
End If 

If CurrentPage = 1 Or nPageCount=0 Then 
Response.Write "<font color=""#CCCCCC"">上一页</font> " 
Else 
Response.Write "<a href=""" & PageName & "?Page=" & CurrentPage-1 & "&Use_Type=" & Use_Type & """>上一页</a> " 
End If 

If CurrentPage = nPageCount Then 
Response.Write "<font color=""#CCCCCC"">下一页</font> " 
Else 
Response.Write "<a href=""" & PageName & "?Page=" & CurrentPage+1 & "&Use_Type=" & Use_Type & """>下一页</a> " 
End If 

If CurrentPage = nPageCount Then 
Response.Write "<font color=""#CCCCCC"">未页</font> " 
Else 
Response.Write "<a href=""" & PageName & "?Page=" & nPageCount &"&Use_Type=" & Use_Type & """>未页</a>" 
End If 
else 
If CurrentPage = 1 Or nPageCount=0 Then 
Response.Write "<font color=""#CCCCCC"">首页</font> " 
Else 
Response.Write "<a href=""" & PageName & "?Keyword=" & Keyword & "&dteFrom=" & odteFrom & "&dteTo=" & odteTo & "&Page=1&Use_Type=" & Use_Type & """>首页</a> " 
End If 

If CurrentPage = 1 Or nPageCount=0 Then 
Response.Write "<font color=""#CCCCCC"">上一页</font> " 
Else 
Response.Write "<a href=""" & PageName & "?Keyword=" & Keyword & "&dteFrom=" & odteFrom & "&dteTo=" & odteTo & "&Page=" & CurrentPage-1 & " &Use_Type=" & Use_Type & """>上一页</a> " 
End If 

If CurrentPage = nPageCount Then 
Response.Write "<font color=""#CCCCCC"">下一页</font> " 
Else 
Response.Write "<a href=""" & PageName & "?Keyword=" & Keyword & "&dteFrom=" & odteFrom & "&dteTo=" & odteTo & "&Page=" & CurrentPage+1 & " &Use_Type=" & Use_Type & """>下一页</a> " 
End If 

If CurrentPage = nPageCount Then 
Response.Write "<font color=""#CCCCCC"">未页</font> " 
Else 
Response.Write "<a href=""" & PageName & "?Keyword=" & Keyword & "&dteFrom=" & odteFrom & "&dteTo=" & odteTo & "&Page=" & nPageCount &" &Use_Type=" & Use_Type & """>未页</a>" 
End If 
end if 
End Sub %> 

编辑页 
Edit.asp 

<!--#include file="Conn.asp"--> 
<% 
Id = Request("Id") 
if Id = "" then 
Response.Write("<script>alert('错误操作');history.go(-1);</script>") 
Response.end() 
end if 

Set Rs = Server.CreateObject("ADODB.RecordSet") 
iSQL = "Select * from data Where Id = " & Id 
Rs.Open iSQL,Conn,1,1 
if Rs.eof and Rs.bof then 
Response.write("<script>alert('数据库出错');history.go(-1);</script>") 
Response.end() 
else 
%> 
<form action="Save_iUseEdit.asp" method="post" name="aForm" id="aForm" onSubmit="return checkReg();"> 
<input type="hidden" name="Id" value="<%=Id%>"> 
<p> 
<input name="xingming" type="text" id="xingming" value="<%=Rs("xingming")%>" maxlength="20" /> 
</p> 
<p> 

<input name="xingbie" type="text" id="xingbie" value="<%=Rs("xingbie")%>" maxlength="20" /> 

</p><input name="" type="submit" value="提交"> 
<input type="reset" name="Submit" value="重置"> 
</form> 


<% 
end if 
Rs.Close 
Set Rs = Nothing 
Conn.Close 
Set Conn = Nothing 
%> 

⌨️ 快捷键说明

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