我用asp的代码修改的时候内容填上并提交了,结果数据的内容被修改成空的了!请教各位?
我用asp的代码显示出了数据库,但是在修改的时候内容填上并提交了,结果数据的内容被修改成空的了!不知道为什么?请教各位?修改页面<%OptionExplicit%><ht...
我用asp的代码显示出了数据库,但是在修改的时候内容填上并提交了,结果数据的内容被修改成空的了!不知道为什么?请教各位?
修改页面
<% Option Explicit %>
<html>
<head>
<title>利用Update语句修改记录示例</title>
<style type="text/css">
<!--
.style1 {font-size: medium}
.STYLE2 {
font-family: "宋体";
color: #0000FF;
}
-->
</style>
</head>
<body>
<h2 align="center" class="STYLE2">修改</h2>
<%
Dim varlink_id
varlink_id=Request.QueryString("link_id") '获取要修改的记录的网站编号
Session("link_id")=varlink_id '保存到Session中,以备upload.asp使用
'以下连接数据库,建立一个Connection对象实例db
Dim db
Set db=Server.CreateObject("ADODB.Connection")
db.Open "Dbq=" & Server.Mappath("wwwlink.mdb")&";Driver={Microsoft Access
Driver (*.mdb)};"
'以下打开记录集
Dim strSql,rs
strSql="Select * From link Where link_id=" & varlink_id
Set rs=db.Execute(strSql)
%>
<center>
<table border="1" bordercolor=red width="90%">
<form name="form1" method="post" action="update.asp" ><tr>
<td>名称</td><td>
<textarea name="content" rows="2" cols="40" wrap="soft"> <%=rs("NAME")%
></textarea></td>
</tr>
<tr>
<td>地址</td><td>
<textarea name="content" rows="2" cols="40" wrap="soft"> <%=rs("URL")%
></textarea></td>
</tr>
<tr>
<td>说明</td><td>
<textarea name="content" rows="5" cols="40" wrap="soft"> <%=rs("inTro")%
></textarea></td>
</tr>
<tr>
<td></td><td><input type="submit" value=" 确 定 ">
<label>
<input type="reset" name="Submit" value="重添">
</label></td>
</tr>
</form>
</table>
</center>
</body>
</html>
update页面代码
<% Option Explicit %>
<%
Dim varlink_id
varlink_id=Session("link_id") '从Session中获取要修改的编号
'如果上面的信息填全了,就修改记录,否则给出提示信息
If Request.Form("content")<>"" Then
'以下连接数据库,建立一个Connection对象实例db
Dim db
Set db=Server.CreateObject("ADODB.Connection")
db.Open "Dbq=" & Server.Mappath("wwwlink.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
'以下修改记录
Dim varNAME,varURL,varinTro,StrSql
varNAME=Request.Form("name") 'update.asp中表单中的input属性中的name值
StrSql="Update link Set name='" & varNAME & "', URL='" & varURL & "', inTro='" & varinTro & "' Where link_id=" & varlink_id
db.Execute(strSql)
Response.Redirect "6-1.asp"
Else
Response.Write "请将所有信息填写完整"
Response.Write "<a href='6-1.asp'>重新修改</a>"
End If
%>
请教大家哪有错误啊 展开
修改页面
<% Option Explicit %>
<html>
<head>
<title>利用Update语句修改记录示例</title>
<style type="text/css">
<!--
.style1 {font-size: medium}
.STYLE2 {
font-family: "宋体";
color: #0000FF;
}
-->
</style>
</head>
<body>
<h2 align="center" class="STYLE2">修改</h2>
<%
Dim varlink_id
varlink_id=Request.QueryString("link_id") '获取要修改的记录的网站编号
Session("link_id")=varlink_id '保存到Session中,以备upload.asp使用
'以下连接数据库,建立一个Connection对象实例db
Dim db
Set db=Server.CreateObject("ADODB.Connection")
db.Open "Dbq=" & Server.Mappath("wwwlink.mdb")&";Driver={Microsoft Access
Driver (*.mdb)};"
'以下打开记录集
Dim strSql,rs
strSql="Select * From link Where link_id=" & varlink_id
Set rs=db.Execute(strSql)
%>
<center>
<table border="1" bordercolor=red width="90%">
<form name="form1" method="post" action="update.asp" ><tr>
<td>名称</td><td>
<textarea name="content" rows="2" cols="40" wrap="soft"> <%=rs("NAME")%
></textarea></td>
</tr>
<tr>
<td>地址</td><td>
<textarea name="content" rows="2" cols="40" wrap="soft"> <%=rs("URL")%
></textarea></td>
</tr>
<tr>
<td>说明</td><td>
<textarea name="content" rows="5" cols="40" wrap="soft"> <%=rs("inTro")%
></textarea></td>
</tr>
<tr>
<td></td><td><input type="submit" value=" 确 定 ">
<label>
<input type="reset" name="Submit" value="重添">
</label></td>
</tr>
</form>
</table>
</center>
</body>
</html>
update页面代码
<% Option Explicit %>
<%
Dim varlink_id
varlink_id=Session("link_id") '从Session中获取要修改的编号
'如果上面的信息填全了,就修改记录,否则给出提示信息
If Request.Form("content")<>"" Then
'以下连接数据库,建立一个Connection对象实例db
Dim db
Set db=Server.CreateObject("ADODB.Connection")
db.Open "Dbq=" & Server.Mappath("wwwlink.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
'以下修改记录
Dim varNAME,varURL,varinTro,StrSql
varNAME=Request.Form("name") 'update.asp中表单中的input属性中的name值
StrSql="Update link Set name='" & varNAME & "', URL='" & varURL & "', inTro='" & varinTro & "' Where link_id=" & varlink_id
db.Execute(strSql)
Response.Redirect "6-1.asp"
Else
Response.Write "请将所有信息填写完整"
Response.Write "<a href='6-1.asp'>重新修改</a>"
End If
%>
请教大家哪有错误啊 展开
6个回答
展开全部
<!--#include file="conn.asp"-->
<!--#include file="admin.asp"-->
<%if Request.QueryString("mark")="southidc" then
id=request("id")
name=request("name")
note=Request("note")
link=Request("link")
LogoURL=Trim(Request.Form("LogoURL"))
OrderID=Trim(Request.Form("OrderID"))
LinkUp=Trim(Request.Form("LinkUp"))
Key=Trim(Request.Form("Key"))
ClassID=Trim(Request.Form("LinkClass"))
If name="" Then
response.write "SORRY <br>"
response.write "请输入网站名称"
response.end
end if
If note="" Then
response.write "SORRY <br>"
response.write "网站说明不能为空"
response.end
end if
If link="http://" Then
response.write "SORRY <br>"
response.write "连接地址不能为空"
response.end
end if
If LogoURL="http://" Then
LogoURL=""
End If
If LinkUp="True" Then
LinkUp=True
Else
LinkUp=False
End If
If Key="True" Then
Key=True
Else
Key=False
End If
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from qq where id="&id
rs.open sql,conn,1,3
rs("name")=name
rs("note")=note
rs("link")=link
Rs("ClassID")=ClassID
Rs("OrderID")=OrderID
rs("LogoURL")=LogoURL
if rs("orderid")<orderid then
strSQL = "UPDATE links SET orderid=orderid-1 WHERE orderid >"&rs("orderid")&" AND orderid<="&orderid
Conn.execute(strSQL)
strSQL = "UPDATE links SET orderid ="&orderid &" WHERE ID="&ID
Conn.execute(strSQL)
end if
if rs("orderid")>orderid then
strSQL ="UPDATE links SET orderid =orderid + 1 WHERE orderid >="&orderid&" AND orderid <"&rs("orderid")
Conn.execute(strSQL)
strSQL = " UPDATE links SET orderid ="&orderid &" WHERE ID="&ID
Conn.execute(strSQL)
end if
rs("LinkUp")=LinkUp
Rs("Key")=Key
rs.update
rs.close
response.redirect "qq.asp"
end if
%>
<%
id=request.querystring("id")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "Select * From qq where id="&id, conn,3,3
ClassID=Rs("ClassID")
%>
<!-- #include file="Inc/Head.asp" -->
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"> <br> <strong><br>
</strong> <br> <br> <table width="700" border="0" cellpadding="2" cellspacing="1" class="table_southidc">
<tr>
<td height="25" class="back_southidc">
<div align="center"><strong>修改在线QQ信息<br>
</strong></div></td>
</tr>
<tr>
<form method="post" action="qq_edit.asp?mark=southidc">
<input type=hidden name=id value=<%=id%>>
<td><div align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ECF5FF">
<!-- <tr>
<td height="25" bgcolor="#A4B6D7"><div align="center">类别名称</div></td>
<td><select id="LinkClass" name="LinkClass">
<option value="0" <%If ClassID="" Then Response.Write("selected")%>>不指定类别</option>
<%
TableName="LinkClass"
Set ClassMenu=Server.CreateObject("ADODB.Recordset")
Sql="Select * From "& TableName &" Where ParentID=0"
ClassMenu.Open Sql,Conn,1,1
For i=1 To Clng(ClassMenu.RecordCount)
If ClassID<>"" And Clng(ClassID)=ClassMenu(0) Then
Selected="selected"
End if
Response.Write("<option value="""&ClassMenu("ID")&""" "&selected&">"&ClassMenu("ClassName")&"</option>")
Selected=""
Call ClassDL1(Clng(ClassMenu(0)))
ClassMenu.Movenext
Next
ClassMenu.Close
Set ClassMenu=NotHing
Sub ClassDL1(ID)
Set RsClass=Server.CreateObject("ADODB.Recordset")
SqlClass="Select * From "& TableName &" Where ParentID="&Clng(ID)
RsClass.Open SqlClass,Conn,1,1
For z=1 To Clng(RsClass.RecordCount)
If ClassID<>"" And Clng(ClassID)=RsClass(0) Then
Selected="selected"
End if
ParentStr=Split(RsClass("ParentStr"),",")
Response.Write("<option value="""&RsClass("ID")&""" "&selected&">")
For x=0 To Clng(UBound(ParentStr))
Response.Write(" ")
Next
Response.Write("├ "&RsClass("ClassName")&"</option>")
selected=""
Call ClassDL1(Clng(RsClass(0)))
RsClass.Movenext
Next
RsClass.Close
Set RsClass=NotHing
End Sub
%>
</select></td>
</tr>-->
<tr>
<td width="27%" height="25" bgcolor="#A4B6D7">
<div align="center">鼠标经过QQ时显示的信息</div></td>
<td width="73%">
<input name="name" type="text" id="name" value="<%=rs("name")%>" size="35" maxlength="40"> </td>
</tr>
<tr>
<td height="22" bgcolor="#A4B6D7">
<div align="center">QQ显示昵称(可随意填写)</div></td>
<td>
<input name="note" type="text" id="note" value="<%=rs("note")%>" size="50" maxlength="120"> </td>
</tr>
<!-- <tr>
<td height="22" bgcolor="#A4B6D7"><div align="center">Logo地址</div></td>
<td><input name="LogoURL" type="text" id="LogoURL" value="<%=rs("LogoURL")%>" size="40" maxlength="50"> </td>
</tr>-->
<tr>
<td height="22" bgcolor="#A4B6D7">
<div align="center">QQ号码(本项必须为数字)</div></td>
<td>
<input name="link" type="text" id="link" value="<%=rs("link")%>" size="35"> </td>
</tr>
<tr>
<td height="22" bgcolor="#A4B6D7"><div align="center">QQ样式1-10种</div></td>
<td><input name="OrderID" type="text" id="OrderID" value="<%=rs("OrderID")%>" size="8"></td>
</tr>
<!-- <tr>
<td height="22" bgcolor="#A4B6D7"><div align="center">是否固定:</div></td>
<td><input name="LinkUp" type="checkbox" id="LinkUp" value="True" <%If Rs("LinkUp")=True Then Response.Write("checked")%>>
固定</td>
</tr>-->
<tr>
<td height="22" bgcolor="#A4B6D7"><div align="center">本QQ是否通过审核</div></td>
<td><input name="Key" type="checkbox" id="LinkUp" value="True" <%If Rs("Key")=True Then Response.Write("checked")%>>
已审核</td>
</tr>
<tr>
<td height="25" colspan="2" bgcolor="#E3E3E3">
<div align="center">
<input name="submit" type="submit" value="确定">
<input name="reset" type="button" value="返回" onClick="javascript:history.go(-1);">
</div></td>
</tr>
</table>
</div></td>
</form>
</tr>
</table></td>
</tr>
</table>
<!-- #include file="Inc/Foot.asp" -->
这是我长用的希望能帮得上 呵呵
http://www.chisha.net
http://www.ezhilian.com
<!--#include file="admin.asp"-->
<%if Request.QueryString("mark")="southidc" then
id=request("id")
name=request("name")
note=Request("note")
link=Request("link")
LogoURL=Trim(Request.Form("LogoURL"))
OrderID=Trim(Request.Form("OrderID"))
LinkUp=Trim(Request.Form("LinkUp"))
Key=Trim(Request.Form("Key"))
ClassID=Trim(Request.Form("LinkClass"))
If name="" Then
response.write "SORRY <br>"
response.write "请输入网站名称"
response.end
end if
If note="" Then
response.write "SORRY <br>"
response.write "网站说明不能为空"
response.end
end if
If link="http://" Then
response.write "SORRY <br>"
response.write "连接地址不能为空"
response.end
end if
If LogoURL="http://" Then
LogoURL=""
End If
If LinkUp="True" Then
LinkUp=True
Else
LinkUp=False
End If
If Key="True" Then
Key=True
Else
Key=False
End If
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from qq where id="&id
rs.open sql,conn,1,3
rs("name")=name
rs("note")=note
rs("link")=link
Rs("ClassID")=ClassID
Rs("OrderID")=OrderID
rs("LogoURL")=LogoURL
if rs("orderid")<orderid then
strSQL = "UPDATE links SET orderid=orderid-1 WHERE orderid >"&rs("orderid")&" AND orderid<="&orderid
Conn.execute(strSQL)
strSQL = "UPDATE links SET orderid ="&orderid &" WHERE ID="&ID
Conn.execute(strSQL)
end if
if rs("orderid")>orderid then
strSQL ="UPDATE links SET orderid =orderid + 1 WHERE orderid >="&orderid&" AND orderid <"&rs("orderid")
Conn.execute(strSQL)
strSQL = " UPDATE links SET orderid ="&orderid &" WHERE ID="&ID
Conn.execute(strSQL)
end if
rs("LinkUp")=LinkUp
Rs("Key")=Key
rs.update
rs.close
response.redirect "qq.asp"
end if
%>
<%
id=request.querystring("id")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "Select * From qq where id="&id, conn,3,3
ClassID=Rs("ClassID")
%>
<!-- #include file="Inc/Head.asp" -->
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"> <br> <strong><br>
</strong> <br> <br> <table width="700" border="0" cellpadding="2" cellspacing="1" class="table_southidc">
<tr>
<td height="25" class="back_southidc">
<div align="center"><strong>修改在线QQ信息<br>
</strong></div></td>
</tr>
<tr>
<form method="post" action="qq_edit.asp?mark=southidc">
<input type=hidden name=id value=<%=id%>>
<td><div align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ECF5FF">
<!-- <tr>
<td height="25" bgcolor="#A4B6D7"><div align="center">类别名称</div></td>
<td><select id="LinkClass" name="LinkClass">
<option value="0" <%If ClassID="" Then Response.Write("selected")%>>不指定类别</option>
<%
TableName="LinkClass"
Set ClassMenu=Server.CreateObject("ADODB.Recordset")
Sql="Select * From "& TableName &" Where ParentID=0"
ClassMenu.Open Sql,Conn,1,1
For i=1 To Clng(ClassMenu.RecordCount)
If ClassID<>"" And Clng(ClassID)=ClassMenu(0) Then
Selected="selected"
End if
Response.Write("<option value="""&ClassMenu("ID")&""" "&selected&">"&ClassMenu("ClassName")&"</option>")
Selected=""
Call ClassDL1(Clng(ClassMenu(0)))
ClassMenu.Movenext
Next
ClassMenu.Close
Set ClassMenu=NotHing
Sub ClassDL1(ID)
Set RsClass=Server.CreateObject("ADODB.Recordset")
SqlClass="Select * From "& TableName &" Where ParentID="&Clng(ID)
RsClass.Open SqlClass,Conn,1,1
For z=1 To Clng(RsClass.RecordCount)
If ClassID<>"" And Clng(ClassID)=RsClass(0) Then
Selected="selected"
End if
ParentStr=Split(RsClass("ParentStr"),",")
Response.Write("<option value="""&RsClass("ID")&""" "&selected&">")
For x=0 To Clng(UBound(ParentStr))
Response.Write(" ")
Next
Response.Write("├ "&RsClass("ClassName")&"</option>")
selected=""
Call ClassDL1(Clng(RsClass(0)))
RsClass.Movenext
Next
RsClass.Close
Set RsClass=NotHing
End Sub
%>
</select></td>
</tr>-->
<tr>
<td width="27%" height="25" bgcolor="#A4B6D7">
<div align="center">鼠标经过QQ时显示的信息</div></td>
<td width="73%">
<input name="name" type="text" id="name" value="<%=rs("name")%>" size="35" maxlength="40"> </td>
</tr>
<tr>
<td height="22" bgcolor="#A4B6D7">
<div align="center">QQ显示昵称(可随意填写)</div></td>
<td>
<input name="note" type="text" id="note" value="<%=rs("note")%>" size="50" maxlength="120"> </td>
</tr>
<!-- <tr>
<td height="22" bgcolor="#A4B6D7"><div align="center">Logo地址</div></td>
<td><input name="LogoURL" type="text" id="LogoURL" value="<%=rs("LogoURL")%>" size="40" maxlength="50"> </td>
</tr>-->
<tr>
<td height="22" bgcolor="#A4B6D7">
<div align="center">QQ号码(本项必须为数字)</div></td>
<td>
<input name="link" type="text" id="link" value="<%=rs("link")%>" size="35"> </td>
</tr>
<tr>
<td height="22" bgcolor="#A4B6D7"><div align="center">QQ样式1-10种</div></td>
<td><input name="OrderID" type="text" id="OrderID" value="<%=rs("OrderID")%>" size="8"></td>
</tr>
<!-- <tr>
<td height="22" bgcolor="#A4B6D7"><div align="center">是否固定:</div></td>
<td><input name="LinkUp" type="checkbox" id="LinkUp" value="True" <%If Rs("LinkUp")=True Then Response.Write("checked")%>>
固定</td>
</tr>-->
<tr>
<td height="22" bgcolor="#A4B6D7"><div align="center">本QQ是否通过审核</div></td>
<td><input name="Key" type="checkbox" id="LinkUp" value="True" <%If Rs("Key")=True Then Response.Write("checked")%>>
已审核</td>
</tr>
<tr>
<td height="25" colspan="2" bgcolor="#E3E3E3">
<div align="center">
<input name="submit" type="submit" value="确定">
<input name="reset" type="button" value="返回" onClick="javascript:history.go(-1);">
</div></td>
</tr>
</table>
</div></td>
</form>
</tr>
</table></td>
</tr>
</table>
<!-- #include file="Inc/Foot.asp" -->
这是我长用的希望能帮得上 呵呵
http://www.chisha.net
http://www.ezhilian.com
参考资料: http://www.yszxw.cn
展开全部
Session("link_id")=varlink_id
你怎么用这个来传ID呢.这个可以记录你ID值到20分钟以后.
<form name="form1" method="post" action="update.asp" >
改为
<form name="form1" method="post" action="update.asp?id=varlink_id" >
把Session("link_id")=varlink_id 去掉
在update.asp页面中
varlink_id=Session("link_id")
改为
varlink_id=Request.QueryString("id")
去试试吧.
按照我的估计,其实你的也是可以修改的,但只能一次吧,后面再改就不行了.
你怎么用这个来传ID呢.这个可以记录你ID值到20分钟以后.
<form name="form1" method="post" action="update.asp" >
改为
<form name="form1" method="post" action="update.asp?id=varlink_id" >
把Session("link_id")=varlink_id 去掉
在update.asp页面中
varlink_id=Session("link_id")
改为
varlink_id=Request.QueryString("id")
去试试吧.
按照我的估计,其实你的也是可以修改的,但只能一次吧,后面再改就不行了.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
StrSql="Update link Set name='" & varNAME & "', URL='" & varURL & "', inTro='" & varinTro & "' Where link_id=" & varlink_id
中的varURL 和varinTro改为Request("varURL")和Request("varinTro")试试
我自己做的网站:http://www.collegeoct.com
如果上面的某些功能你想实现的话,我可以给你一些代码。
QQ:287394875
中的varURL 和varinTro改为Request("varURL")和Request("varinTro")试试
我自己做的网站:http://www.collegeoct.com
如果上面的某些功能你想实现的话,我可以给你一些代码。
QQ:287394875
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
更新语句太乱了,建议你这么写
sql="select * from link where link_id="&varlink_id
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
rs("name")=varNAME
rs("URL")=varURL
rs("inTro")=varinTro
rs.update
sql="select * from link where link_id="&varlink_id
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
rs("name")=varNAME
rs("URL")=varURL
rs("inTro")=varinTro
rs.update
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
数据库字段类型有没有错误呢?
参考资料: asp
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询