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

新人发帖。。请高手赐教

wangyangjun 发布于 2009-10-08 00:28, 541 次点击
我想从数据库data里面left right 字符段读出来。然后定义一个tion值
当tion="左边" 左边为0  右边等于1时  弹出提示左边不能添加数据
当tion="右边" 右边为0  左边等于1时  弹出提示右边不能添加数据

其他条件都成立

谢谢大家!
3 回复
#2
wangyangjun2009-10-08 00:31
<%response.End  
set rs=server.CreateObject("adodb.recordset")
sql ="select Left,Right from data where gs='" & gs & "'"
rs.open sql,conn,3,2  
if tion="左边" then
  if rs("left")=0 then
   if rs("Right")=1 then%>
               <script language="javascript">
                alert("左边不行");
                history.back();
            </script>
<%response.End  
end if
end if
end if
If tion="右边" then     
  if rs("Right")=0 then
   if rs("Left")=1 then%>
                  <script language="javascript">
                alert("右边不行");
                history.back();
            </script>
<%response.End  
end if
end if
end if
%>

这个是我自己瞎弄的!就是没效果。。很郁闷
#3
anjincheng2009-10-08 21:36
<%
set rs=server.CreateObject("adodb.recordset")  
sql ="select Left,Right from data where gs='" & gs & "'"  
rs.open sql,conn,3,2   
%>
<%
tion=request.form("tion")
if (tion=Left(Left) and Left(Left)=0 and Right(Right)=1) then
response.Write "对不起!左边不能添加数据 !"
else
rs.addnew  
     rs("Right")=Right
     rs.update
if (tion=Right(Right) and Right(Right)=0 and Left(Left)=1) then
response.Write "对不起!右边不能添加数据 !"
else
rs.addnew   
     rs("Left")=Left
     rs.update
end if
end if

%>
#4
aspic2009-10-09 09:42
程序代码:
<%
Set Rs = CreateObject("Adodb.RecordSet")
Sql = "Select Top 1 [Left], [Right] From Data Where 你的查询条件"
Rs.Open Sql,Conn,3,2
'tion,Left,Right根据自己的需要从不同途径获取
If tion = "左边" And Rs("Left") = 0 And Rs("Right") = 1 Then
    Response.Write "<script>alert(""Sorry!左边不能添加数据!"")</script>"
    Response.End()
ElseIf  tion = "右边" And Rs("Right") = 0 And Rs("Left") = 1 Then
    Response.Write "<script>alert(""Sorry!右边不能添加数据!"")</script>"
    Response.End()
Else
    Rs.AddNew
    Rs("Left") = Left
    Rs("Right") = Right
    Rs.Update
End If
Rs.Close
Set Rs = Nothing
%>
1