在ASP中怎么对查询到的数据进行修改
我做了一个查询的页面现在怎么样才可以对查询到的数据进行修改并且保存<%OrderNum=Request.form("vip_Id")IFSession("UserName...
我做了一个查询的页面
现在怎么样才可以对查询到的数据进行修改并且保存
<%
OrderNum=Request.form("vip_Id")
IF Session("UserName")="" Then
response.redirect "server.asp"
Else
set Rs =Server.CreateObject("Adodb.RecordSet")
sql="select khmc,dh,hyljjfz,viph,csrq from khda where viph='01"&OrderNum&"'"
Rs.Open SQL,Conn,1,1,&H0001
IF rs.RecordCount >=1 then
%>
<body>
<br> <div align="center">
<center>
<table width="560" border="0" cellpadding="2" cellspacing="1" bgcolor="ECF5FF" class="table_southidc">
<TR align=center class='title'>
<TD class="back_southidc" height=25 colSpan=2><b>修改注册用户信息</b></TD>
</TR>
<TR class="tdbg" >
<TD width="120" align="right"><strong><font color="#000000">会员名称</font>:</strong></TD>
<TD><INPUT maxLength=100 size=30 name=homepage value="<%=rs("khmc")%>"></TD>
</TR>
<TR class="tdbg" >
<TD width="120" align="right"><strong>生日:</strong></TD>
<TD><INPUT name=Comane value="<%=rs("csrq")%>" size=30 maxLength=20></TD>
</TR>
<TR class="tdbg" >
<TD width="120" align="right"><strong><font color="#000000">电话</font>:</strong></TD>
<TD><INPUT name=Add value="<%=rs("dh")%>" size=30 maxLength=50></TD>
</TR>
<TR class="tdbg" >
<TD align="right"><strong><font color="#000000">积分</font>:</strong></TD>
<TD><INPUT name=Somane value="<%=rs("hyljjfz")%>" size=30 maxLength=50></TD>
</TR>
<TR align="center" class="tdbg" >
<TD height="40" colspan="2"><input name="Action" type="hidden" id="Action" value="Modify">
<input name=Submit type=submit id="Submit" value="保存修改结果">
<input name="UserID" type="hidden" id="UserID" value="<%=rs("viph")%>"></TD>
</TR>
</TABLE>
<p> </p>
</div>
</form>
<p>
<%
Else
response.redirect "Logins.asp?msg=您输入的VIP号不存在或格式不正确,请重新输入!"
End IF
End if
rs.close
conn.close
%>
<p>
</body>
</html>
高手帮忙!!!
根据niewenmin的答案我做了2个页面
修改页edit.asp
保存页save.asp
<!--#include file="Inc/Conn1.asp" -->
<%
dh = Request("dh")
hyljjfz = Request("hyljjfz")
id = Request("id")
Set iRs = Server.CreateObject("ADODB.RecordSet")
iSQL = "Select * from khda where viph='01"&id&"'"
iRs.Open iSQL,Conn,1,3
iRs.AddNew
iRs("dh")=dh
iRs("hyljjfz")=hyljjfz
iRs.Update
iRs.Close()
Set iRs = Nothing
Conn.Close()
Set Conn = Nothing
Response.Write("<script>alert('添加数据成功');location.href='vip.asp';</script>")
%>
显示错误:
无法将 NULL 值插入列 'ckrq',表 'naosoft.dbo.khda';该列不允许空值。/Save.asp, 第 14 行 展开
现在怎么样才可以对查询到的数据进行修改并且保存
<%
OrderNum=Request.form("vip_Id")
IF Session("UserName")="" Then
response.redirect "server.asp"
Else
set Rs =Server.CreateObject("Adodb.RecordSet")
sql="select khmc,dh,hyljjfz,viph,csrq from khda where viph='01"&OrderNum&"'"
Rs.Open SQL,Conn,1,1,&H0001
IF rs.RecordCount >=1 then
%>
<body>
<br> <div align="center">
<center>
<table width="560" border="0" cellpadding="2" cellspacing="1" bgcolor="ECF5FF" class="table_southidc">
<TR align=center class='title'>
<TD class="back_southidc" height=25 colSpan=2><b>修改注册用户信息</b></TD>
</TR>
<TR class="tdbg" >
<TD width="120" align="right"><strong><font color="#000000">会员名称</font>:</strong></TD>
<TD><INPUT maxLength=100 size=30 name=homepage value="<%=rs("khmc")%>"></TD>
</TR>
<TR class="tdbg" >
<TD width="120" align="right"><strong>生日:</strong></TD>
<TD><INPUT name=Comane value="<%=rs("csrq")%>" size=30 maxLength=20></TD>
</TR>
<TR class="tdbg" >
<TD width="120" align="right"><strong><font color="#000000">电话</font>:</strong></TD>
<TD><INPUT name=Add value="<%=rs("dh")%>" size=30 maxLength=50></TD>
</TR>
<TR class="tdbg" >
<TD align="right"><strong><font color="#000000">积分</font>:</strong></TD>
<TD><INPUT name=Somane value="<%=rs("hyljjfz")%>" size=30 maxLength=50></TD>
</TR>
<TR align="center" class="tdbg" >
<TD height="40" colspan="2"><input name="Action" type="hidden" id="Action" value="Modify">
<input name=Submit type=submit id="Submit" value="保存修改结果">
<input name="UserID" type="hidden" id="UserID" value="<%=rs("viph")%>"></TD>
</TR>
</TABLE>
<p> </p>
</div>
</form>
<p>
<%
Else
response.redirect "Logins.asp?msg=您输入的VIP号不存在或格式不正确,请重新输入!"
End IF
End if
rs.close
conn.close
%>
<p>
</body>
</html>
高手帮忙!!!
根据niewenmin的答案我做了2个页面
修改页edit.asp
保存页save.asp
<!--#include file="Inc/Conn1.asp" -->
<%
dh = Request("dh")
hyljjfz = Request("hyljjfz")
id = Request("id")
Set iRs = Server.CreateObject("ADODB.RecordSet")
iSQL = "Select * from khda where viph='01"&id&"'"
iRs.Open iSQL,Conn,1,3
iRs.AddNew
iRs("dh")=dh
iRs("hyljjfz")=hyljjfz
iRs.Update
iRs.Close()
Set iRs = Nothing
Conn.Close()
Set Conn = Nothing
Response.Write("<script>alert('添加数据成功');location.href='vip.asp';</script>")
%>
显示错误:
无法将 NULL 值插入列 'ckrq',表 'naosoft.dbo.khda';该列不允许空值。/Save.asp, 第 14 行 展开
1个回答
展开全部
sql="select * from khda where viph='01"&OrderNum&"'"
数据连接页
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
%>
保存编辑页比较简单,篇幅不够,就自己写下了,如果需要我帮忙的话再短信联系!
回答者:niewenmin - 初入江湖 三级 11
数据连接页
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
%>
保存编辑页比较简单,篇幅不够,就自己写下了,如果需要我帮忙的话再短信联系!
回答者:niewenmin - 初入江湖 三级 11
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询