如何在asp同一页面操作两个表
数据库有a与b两个表,首先要查a表中的a1字段是否有"12345"的记录,有的话才让查询b表中的b1字段是否有"xxxx",如果没有则执行增加记录,有的话则写出"no"请...
数据库有a与b两个表,首先要查a表中的a1字段是否有"12345"的记录,有的话才让查询b表中的b1字段是否有"xxxx",如果没有则执行增加记录,有的话则写出"no"
请问这应该怎么写,
set rs1=server.createobject("adodb.recordset")
sqlinfo="select * from [a] where a1='12345'"
rs1.open sqlinfo,conn
If err.number = 0 Then
If rs1.bof and rs1.eof Then
response.Write("no")
else
set rs2=server.createobject("adodb.recordset")
sqlinfo="select * from [b] where b1='xxxx'"
rs2.open sqlinfo,conn
If err.number = 0 Then
If rs2.bof and rs2.eof Then
rs.addnew
rs("b1")="99999" rs.update
response.Write("ok")
Else
response.Write("no")
End If
End If
End If
End If
rs1.close
set rs1= nothing
rs2.close
set rs2= nothing
conn.close
set conn=nothing
这代码不对 展开
请问这应该怎么写,
set rs1=server.createobject("adodb.recordset")
sqlinfo="select * from [a] where a1='12345'"
rs1.open sqlinfo,conn
If err.number = 0 Then
If rs1.bof and rs1.eof Then
response.Write("no")
else
set rs2=server.createobject("adodb.recordset")
sqlinfo="select * from [b] where b1='xxxx'"
rs2.open sqlinfo,conn
If err.number = 0 Then
If rs2.bof and rs2.eof Then
rs.addnew
rs("b1")="99999" rs.update
response.Write("ok")
Else
response.Write("no")
End If
End If
End If
End If
rs1.close
set rs1= nothing
rs2.close
set rs2= nothing
conn.close
set conn=nothing
这代码不对 展开
2个回答
展开全部
set rs1=server.createobject("adodb.recordset")
sqlinfo="select * from [b] where b1='xxxx' and exists (select * from [a] where a1='祥唤者12345')"谨薯
rs1.open sqlinfo,conn
If err.number = 0 Then
If rs1.bof and rs1.eof Then
response.Write("no")
else
conn.Execute ("链棚insert into [b] (b1) values ('99999')")
End If
End If
rs1.close
set rs1= nothing
conn.close
set conn=nothing
sqlinfo="select * from [b] where b1='xxxx' and exists (select * from [a] where a1='祥唤者12345')"谨薯
rs1.open sqlinfo,conn
If err.number = 0 Then
If rs1.bof and rs1.eof Then
response.Write("no")
else
conn.Execute ("链棚insert into [b] (b1) values ('99999')")
End If
End If
rs1.close
set rs1= nothing
conn.close
set conn=nothing
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询