asp 修改记录
<%id=trim(Request.form("id"))Title=Trim(request.form("Title"))BigClassName=trim(reque...
<%
id=trim(Request.form("id"))
Title=Trim(request.form("Title"))
BigClassName=trim(request.form("BigClassName"))
'SmallClassName=trim(request.form("SmallClafssName"))
Content=trim(request.form("Content"))
User=Trim(request.form("User"))
AddDate=trim(request.form("AddDate"))
orderid=trim(request.form("orderid"))
'FirstImageName=trim(request.form("DefaultPicUrl"))
'Ok=Trim(request.form("Ok"))
'Hits=trim(request.form("Hits"))
Action=trim(request("Action"))
lan=trim(request.form("lan"))
if Title="" then
founderr=true
errmsg="<li>新闻标题不能为空</li>"
end if
if Content="" then
founderr=true
errmsg=errmsg+"<li>新闻内容不能为空</li>"
end if
Title=dvhtmlencode(Title)
if AddDate<>"" and IsDate(AddDate)=true then
AddDate=CDate(AddDate)
else
AddDate=now()
end if
set rs=server.createobject("adodb.recordset")
select case Action
case "Add"
sql="select * from News where (id is null)"
rs.open sql,conn,1,3
rs.addnew
call SaveData()
rs.update
rs.close
set rs=nothing
response.redirect "News_Manage.asp"
case "modi"
sql="select * from News where id="&id
rs.open sql,conn,1,3
if id<>"" then
call SaveData()
rs.update
rs.close
set rs=nothing
response.write ("修改成功")
'response.redirect "News_Manage.asp"
else
founderr=true
errmsg=errmsg+"<li>找不到此ID的记录,可能已经被其他人删除。</li>"
end if
Case else
founderr=true
errmsg=errmsg+"<li>没有选定参数</li>"
call WriteErrMsg()
end select
call CloseConn()
%>
<%
sub SaveData()
rs("Title")=Title
rs("Content")=Content
rs("User")=User
rs("BigClassName")=BigClassName
rs("AddDate")=AddDate
rs("orderid")=orderid
rs("lan")=lan
end sub
%>
显示修改成功,但 数据库里的数据还是没变啊?
各位说的我都试过了,数据还是修改不了 展开
id=trim(Request.form("id"))
Title=Trim(request.form("Title"))
BigClassName=trim(request.form("BigClassName"))
'SmallClassName=trim(request.form("SmallClafssName"))
Content=trim(request.form("Content"))
User=Trim(request.form("User"))
AddDate=trim(request.form("AddDate"))
orderid=trim(request.form("orderid"))
'FirstImageName=trim(request.form("DefaultPicUrl"))
'Ok=Trim(request.form("Ok"))
'Hits=trim(request.form("Hits"))
Action=trim(request("Action"))
lan=trim(request.form("lan"))
if Title="" then
founderr=true
errmsg="<li>新闻标题不能为空</li>"
end if
if Content="" then
founderr=true
errmsg=errmsg+"<li>新闻内容不能为空</li>"
end if
Title=dvhtmlencode(Title)
if AddDate<>"" and IsDate(AddDate)=true then
AddDate=CDate(AddDate)
else
AddDate=now()
end if
set rs=server.createobject("adodb.recordset")
select case Action
case "Add"
sql="select * from News where (id is null)"
rs.open sql,conn,1,3
rs.addnew
call SaveData()
rs.update
rs.close
set rs=nothing
response.redirect "News_Manage.asp"
case "modi"
sql="select * from News where id="&id
rs.open sql,conn,1,3
if id<>"" then
call SaveData()
rs.update
rs.close
set rs=nothing
response.write ("修改成功")
'response.redirect "News_Manage.asp"
else
founderr=true
errmsg=errmsg+"<li>找不到此ID的记录,可能已经被其他人删除。</li>"
end if
Case else
founderr=true
errmsg=errmsg+"<li>没有选定参数</li>"
call WriteErrMsg()
end select
call CloseConn()
%>
<%
sub SaveData()
rs("Title")=Title
rs("Content")=Content
rs("User")=User
rs("BigClassName")=BigClassName
rs("AddDate")=AddDate
rs("orderid")=orderid
rs("lan")=lan
end sub
%>
显示修改成功,但 数据库里的数据还是没变啊?
各位说的我都试过了,数据还是修改不了 展开
展开全部
你只是执行了一句select,当然无法修改
case "modi"
sql="select * from News where id="&id
rs.open sql,conn,1,3
if id<>"" then
call SaveData()
rs.update
rs.close
把select * ...改为update news set .............
case "modi"
sql="select * from News where id="&id
rs.open sql,conn,1,3
if id<>"" then
call SaveData()
rs.update
rs.close
把select * ...改为update news set .............
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
rs.open sql,conn,1,3
if id<>"" then
call SaveData()
rs.update
rs.close
set rs=nothing
response.write ("修改成功")
这个给rs字段赋值不可放到过程里面调用的
应该这样
<%
id=trim(Request.form("id"))
Title=Trim(request.form("Title"))
BigClassName=trim(request.form("BigClassName"))
'SmallClassName=trim(request.form("SmallClafssName"))
Content=trim(request.form("Content"))
User=Trim(request.form("User"))
AddDate=trim(request.form("AddDate"))
orderid=trim(request.form("orderid"))
'FirstImageName=trim(request.form("DefaultPicUrl"))
'Ok=Trim(request.form("Ok"))
'Hits=trim(request.form("Hits"))
Action=trim(request("Action"))
lan=trim(request.form("lan"))
if Title="" then
founderr=true
errmsg="<li>新闻标题不能为空</li>"
end if
if Content="" then
founderr=true
errmsg=errmsg+"<li>新闻内容不能为空</li>"
end if
Title=dvhtmlencode(Title)
if AddDate<>"" and IsDate(AddDate)=true then
AddDate=CDate(AddDate)
else
AddDate=now()
end if
set rs=server.createobject("adodb.recordset")
select case Action
case "Add"
sql="select * from News where (id is null)"
rs.open sql,conn,1,3
rs.addnew
call SaveData()
rs.update
rs.close
set rs=nothing
response.redirect "News_Manage.asp"
case "modi"
sql="select * from News where id="&id
rs.open sql,conn,1,3
if id<>"" then
rs("Title")=Title
rs("Content")=Content
rs("User")=User
rs("BigClassName")=BigClassName
rs("AddDate")=AddDate
rs("orderid")=orderid
rs("lan")=lan
rs.update
rs.close
set rs=nothing
response.write ("修改成功")
'response.redirect "News_Manage.asp"
else
founderr=true
errmsg=errmsg+"<li>找不到此ID的记录,可能已经被其他人删除。</li>"
end if
Case else
founderr=true
errmsg=errmsg+"<li>没有选定参数</li>"
call WriteErrMsg()
end select
call CloseConn()
%>
<%
sub SaveData()
rs("Title")=Title
rs("Content")=Content
rs("User")=User
rs("BigClassName")=BigClassName
rs("AddDate")=AddDate
rs("orderid")=orderid
rs("lan")=lan
end sub
%>
if id<>"" then
call SaveData()
rs.update
rs.close
set rs=nothing
response.write ("修改成功")
这个给rs字段赋值不可放到过程里面调用的
应该这样
<%
id=trim(Request.form("id"))
Title=Trim(request.form("Title"))
BigClassName=trim(request.form("BigClassName"))
'SmallClassName=trim(request.form("SmallClafssName"))
Content=trim(request.form("Content"))
User=Trim(request.form("User"))
AddDate=trim(request.form("AddDate"))
orderid=trim(request.form("orderid"))
'FirstImageName=trim(request.form("DefaultPicUrl"))
'Ok=Trim(request.form("Ok"))
'Hits=trim(request.form("Hits"))
Action=trim(request("Action"))
lan=trim(request.form("lan"))
if Title="" then
founderr=true
errmsg="<li>新闻标题不能为空</li>"
end if
if Content="" then
founderr=true
errmsg=errmsg+"<li>新闻内容不能为空</li>"
end if
Title=dvhtmlencode(Title)
if AddDate<>"" and IsDate(AddDate)=true then
AddDate=CDate(AddDate)
else
AddDate=now()
end if
set rs=server.createobject("adodb.recordset")
select case Action
case "Add"
sql="select * from News where (id is null)"
rs.open sql,conn,1,3
rs.addnew
call SaveData()
rs.update
rs.close
set rs=nothing
response.redirect "News_Manage.asp"
case "modi"
sql="select * from News where id="&id
rs.open sql,conn,1,3
if id<>"" then
rs("Title")=Title
rs("Content")=Content
rs("User")=User
rs("BigClassName")=BigClassName
rs("AddDate")=AddDate
rs("orderid")=orderid
rs("lan")=lan
rs.update
rs.close
set rs=nothing
response.write ("修改成功")
'response.redirect "News_Manage.asp"
else
founderr=true
errmsg=errmsg+"<li>找不到此ID的记录,可能已经被其他人删除。</li>"
end if
Case else
founderr=true
errmsg=errmsg+"<li>没有选定参数</li>"
call WriteErrMsg()
end select
call CloseConn()
%>
<%
sub SaveData()
rs("Title")=Title
rs("Content")=Content
rs("User")=User
rs("BigClassName")=BigClassName
rs("AddDate")=AddDate
rs("orderid")=orderid
rs("lan")=lan
end sub
%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
语法似乎没错啊
你要看看从表单中获得的id是否错误
从表单的获得的值是否存在
你可以用response.write输出看看
你要看看从表单中获得的id是否错误
从表单的获得的值是否存在
你可以用response.write输出看看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询