注册 登录
编程论坛 ASP技术论坛

关于一个数据写入的问题,请指教

aiwobbs 发布于 2011-11-02 11:16, 537 次点击
我的biaoxiu 表有 wxry wxry1.....wxry9 10个字段 我现在要在里面写上登陆人的名字 判断wxry不是空就写到wxry1一直推下去 怎么写

if request("action")="cj" then
set rs=server.createobject("adodb.recordset")
sqltext="select * from baoxiu where id=" & request("id")
rs.open sqltext,conn,3,3

'更新记录到数据库
rs("wxry")=realname
rs.update
rs.close
conn.close
  response.redirect "weixiu.asp?action=sl1&bxid="&request("bxid")&"&wxly="&request("wxly")&"&wxfk=2"
end if
4 回复
#2
yms1232011-11-02 11:30
固定wxry只有10个的话可以这样写
set rs=server.createobject("adodb.recordset")
sqltext="select * from baoxiu where id=" & request("id")
rs.open sqltext,conn,1,1
if rs.eof then
   response.write "没有找到数据"
else
   dim iNull,i
   iNull=false
   For i=0 To 9
     if i=0 Then
        if rs("wxry")="" Then
           iNull=true
        end if
     else
        if rs("wxry"&i)="" Then
           iNull=true
        end if
     end if
   Next
   if iNull=true then
      response.write "有空值"
   else
      response.write "无空值"
   end if
end if
#3
aiwobbs2011-11-02 11:49
谢谢帮助,不过运行不了


<%
if shenfen="1" or shenfen="3" then
  if Not post_chk() Then
  response.write"<script>alert('禁止从外部站点提交数据! ');location.replace('index.asp')</script>"
  else  
if request("action")="cj" then
set rs=server.createobject("adodb.recordset")
sqltext="select * from baoxiu where id=" & request("id")
rs.open sqltext,conn,3,3
if rs.eof then
   response.write "没有找到数据"
else
   dim iNull,i
   iNull=false
   For i=0 To 9
     if i=0 Then
        if rs("wxry")="" Then
           iNull=true
        end if
     else
        if rs("wxry"&i)="" Then
           iNull=true
        end if
     end if


'更新记录到数据库
rs("wxry"&i)=realname
rs.update
rs.close
conn.close
  response.redirect "weixiu.asp?action=sl1&bxid="&request("bxid")&"&wxly="&request("wxly")&"&wxfk=2"
end if

if request("action")="sl" then
set rs=server.createobject("adodb.recordset")
sqltext="select * from baoxiu where id=" & request("id")
rs.open sqltext,conn,3,3

'更新记录到数据库
rs("wxry")=realname
rs("weixiu")=request("wxfk")
rs("sfjr")=request("sfjr")
rs("wxtime")=now()
rs.update
rs.close
conn.close
  response.redirect "weixiu.asp?action=sl1&bxid="&request("bxid")&"&wxly="&request("wxly")&"&wxfk=2"
end if

if request("action")="sl1" then

set rs2=server.createobject("adodb.recordset")
sqltext2="select * from jilu"
rs2.open sqltext2,conn,3,3

'更新记录到数据库
rs2.addnew
rs2("wxry")=realname
rs2("bxid")=request("bxid")
rs2("wxfk")=request("wxfk")
rs2("weixiu")=request("wxfk")
if request("wxly")="" then
rs2("wxly")="正在维修中,请耐心等待"
else
rs2("wxly")=request("wxly")
end if
rs2("wxtime")=now()

rs2.update
rs2.close
conn.close
response.write"<script>alert('受理成功! ');location.replace('index.asp?T=shouli')</script>"
       end if


if request("action")="ok" then
set rs=server.createobject("adodb.recordset")
sqltext="select * from baoxiu where id=" & request("id")
rs.open sqltext,conn,3,3

'更新记录到数据库

rs("wxry")=realname
rs("weixiu")=request("wxfk")
rs("wxtime")=now()
rs("tjtime")=date()

rs.update
rs.close
conn.close
  response.redirect "weixiu.asp?action=ok1&bxid="&request("bxid")&"&wxfk=1"
end if

if request("action")="ok1" then
set rs2=server.createobject("adodb.recordset")
sqltext2="select * from jilu"
rs2.open sqltext2,conn,3,3

'更新记录到数据库
rs2.addnew
rs2("wxry")=realname
rs2("bxid")=request("bxid")
rs2("wxfk")=request("wxfk")
rs2("weixiu")=request("wxfk")
rs2("wxtime")=now()

rs2.update
rs2.close
conn.close
response.write"<script>alert('维修成功! ');location.replace('index.asp?T=shouli')</script>"
end if


if request("action")="fq" then
if request("wxly")="" then
response.write "<script language=JavaScript>" & chr(13) & "alert('请输入放弃原因!');" & "history.back()" & "</script>"
response.End
end if
set rs=server.createobject("adodb.recordset")
sqltext="select * from baoxiu where id=" & request("id")
rs.open sqltext,conn,3,3

'更新记录到数据库

rs("weixiu")=request("wxfk")
rs("wxtime")=now()

rs.update
rs.close
conn.close
response.redirect "weixiu.asp?action=fq1&bxid="&request("bxid")&"&wxly="&request("wxly")&"&wxfk=0"
end if

if request("action")="fq1" then
set rs2=server.createobject("adodb.recordset")
sqltext2="select * from jilu"
rs2.open sqltext2,conn,3,3

'更新记录到数据库
rs2.addnew
rs2("wxry")=realname
rs2("bxid")=request("bxid")
rs2("wxfk")=request("wxfk")
rs2("weixiu")=request("wxfk")
rs2("wxly")=request("wxly")
rs2("wxtime")=now()

rs2.update
rs2.close
conn.close
response.write"<script>alert('成功放弃维修! ');location.replace('index.asp?T=shouli')</script>"
end if
end if
else
response.write"<script>alert('对不起,您没有权限! ');location.replace('index.asp')</script>"
end if
     %>
#4
yms1232011-11-02 12:20
   For i=0 To 9
     if i=0 Then
        if rs("wxry")="" Then
           iNull=true
        end if
     else
        if rs("wxry"&i)="" Then
           iNull=true
        end if
     end if
next 'for循环要加next
#5
aiwobbs2011-11-03 09:01
试了,可以运行,但是数据写不进去
1