asp+access数据查询
我有两张表一个user(id,username,password)一个data(id,username,xingming,xingbie)我想实现当用户登陆后可以往dat...
我有两张表 一个user(id,username,password) 一个data(id,username,xingming,xingbie)
我想实现当用户登陆后可以往data里面提交数据
然后有个查看选项可以查看当前登陆用户所提交的数据
还有个修改页面可以显示当前登陆用户提交的数据并且能对这些数据进行修改 展开
我想实现当用户登陆后可以往data里面提交数据
然后有个查看选项可以查看当前登陆用户所提交的数据
还有个修改页面可以显示当前登陆用户提交的数据并且能对这些数据进行修改 展开
4个回答
展开全部
数据连接页
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
%>
保存编辑页比较简单,篇幅不够,就自己写下了,如果需要我帮忙的话再短信联系!
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
%>
保存编辑页比较简单,篇幅不够,就自己写下了,如果需要我帮忙的话再短信联系!
展开全部
晕倒,这个ASP比较简单的东西啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
set rs=Server.CreateObject(\"adodb.connection\")
sql=\"select * from 表名\"
rs.open sql,conn,1,2
sql=\"select * from 表名\"
rs.open sql,conn,1,2
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
麻烦
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询