asp数据库更新语句出问题
哪位大神帮忙看一下代码<form><%dimconn,strConnsetconn=server.CreateObject("ADODB.connection")strC...
哪位大神帮忙看一下代码
<form>
<%
dim conn,strConn
set conn=server.CreateObject("ADODB.connection")
strConn="provider=Microsoft.jet.oledb.4.0;data source=" & server.MapPath("xxxxx/ruan11405020.mdb")
conn.open strConn
dim rs
set rs=conn.execute("select * from My")
%>
......
<% '下面建立SQL语句,因为某些字段允许为空,所以需要判断一下
strConn="update My set state='"&Request.Form("state")&"',settemper='"&Request.Form("settemper")&"',roomtemper='"&Request.Form("roomtemper")&"',setwet='"&Request.Form("setwet")&"',setclear='"&Request.Form("setclear")&"',moshi='"&Request.Form("moshi")&"',chksleep='"&Request.Form("chksleep")&"',chkfangmei='"&Request.Form("chkfangmei")&"',chkhealth='"&Request.Form("chkhealth")&"',chkeco='"&Request.Form("chkeco")&"',chkpowe=r'"&Request.Form("chkpower")&"',chknumber='"&Request.Form("chknumber")&"',windspeed='"&Request.Form("windspeed")&"',windxiang='"&Request.Form("windxiang")&"',chkshuiping='"&Request.Form("chkshuiping")&"',chkchuizhi='"&Request.Form("chkchuizhi")&"',litisongf='"&Request.Form("litisongf")&"',manopen='"&Request.Form("manopen")&"',settime1='"&Request.Form("settime1")&"',settime2='"&Request.Form("settime2")&"'where ID = "1
rs.Execute(strConn)
'关闭对象
Set rs=Nothing
rs.close
Response.Redirect ""
End If
%>
</form> 展开
<form>
<%
dim conn,strConn
set conn=server.CreateObject("ADODB.connection")
strConn="provider=Microsoft.jet.oledb.4.0;data source=" & server.MapPath("xxxxx/ruan11405020.mdb")
conn.open strConn
dim rs
set rs=conn.execute("select * from My")
%>
......
<% '下面建立SQL语句,因为某些字段允许为空,所以需要判断一下
strConn="update My set state='"&Request.Form("state")&"',settemper='"&Request.Form("settemper")&"',roomtemper='"&Request.Form("roomtemper")&"',setwet='"&Request.Form("setwet")&"',setclear='"&Request.Form("setclear")&"',moshi='"&Request.Form("moshi")&"',chksleep='"&Request.Form("chksleep")&"',chkfangmei='"&Request.Form("chkfangmei")&"',chkhealth='"&Request.Form("chkhealth")&"',chkeco='"&Request.Form("chkeco")&"',chkpowe=r'"&Request.Form("chkpower")&"',chknumber='"&Request.Form("chknumber")&"',windspeed='"&Request.Form("windspeed")&"',windxiang='"&Request.Form("windxiang")&"',chkshuiping='"&Request.Form("chkshuiping")&"',chkchuizhi='"&Request.Form("chkchuizhi")&"',litisongf='"&Request.Form("litisongf")&"',manopen='"&Request.Form("manopen")&"',settime1='"&Request.Form("settime1")&"',settime2='"&Request.Form("settime2")&"'where ID = "1
rs.Execute(strConn)
'关闭对象
Set rs=Nothing
rs.close
Response.Redirect ""
End If
%>
</form> 展开
1个回答
展开全部
两种方案
方案一:
Dim checked_job
checked_job = request.Form("checked")
response.Write checked_job
Dim each_id,sql,rs
For I=1 to request.Form("id").count
each_id = request.Form("id")(I)
conn.execute ("update materiel_list set checked = '"& checked_job &"' where id = "& each_id )
Next
方案二:
Dim checked_job
checked_job = request.Form("checked")
response.Write checked_job
Dim each_id,sql,rs
For I=1 to request.Form("id").count
each_id = request.Form("id")(I)
set rs=server.CreateObject("adodb.recordset")
Sql="select checked from materiel_list where id = "& each_id
rs.Open sql,db,1,3
if not(rs.eof and rs.bof) then
checked = checked_job
rs.update
end if
rs.close
set rs=nothing
Next
这样可以么?
方案一:
Dim checked_job
checked_job = request.Form("checked")
response.Write checked_job
Dim each_id,sql,rs
For I=1 to request.Form("id").count
each_id = request.Form("id")(I)
conn.execute ("update materiel_list set checked = '"& checked_job &"' where id = "& each_id )
Next
方案二:
Dim checked_job
checked_job = request.Form("checked")
response.Write checked_job
Dim each_id,sql,rs
For I=1 to request.Form("id").count
each_id = request.Form("id")(I)
set rs=server.CreateObject("adodb.recordset")
Sql="select checked from materiel_list where id = "& each_id
rs.Open sql,db,1,3
if not(rs.eof and rs.bof) then
checked = checked_job
rs.update
end if
rs.close
set rs=nothing
Next
这样可以么?
追问
请问可以分析一下我的代码吗?我不知道哪里出错了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询