希诺以及各位大虾快来帮忙,大难题,搞不定,关于数据库的?

memgarden 2002-05-08 10:49:31
现在有两个表,A表里面有disid,B表里面有ctrlid,disid1,disid2,从页面传过来一个变量selectedctrlid,现在我想通过selectedctrlid=ctrlid查出A表的disid,我的sql语句如下:
strselect="select disid from A,B where ctrlid="& selectedctrlid&" and (disid=disid1 or disid=disid2) order by disid"
我现在的问题是我无法知道A表中disid到底是通过B表的disid1查出的,还是disid2查出,如果知道是通过disid1查的就显示,广域网,否则就显示局域网。
...全文
6 点赞 收藏 10
写回复
10 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
memgarden 2002-05-08
<%
sub addItem()
%>
<center>
专线工单IP使用申请
<P>
<FORM name=addItem action="ipdisadd.asp?action=add&step=addfirst" method=post>
<TABLE borderColor=#8080ff bgColor=#bcecfa border=1 width=70%>
<tr>
<td rowspan=5>
选择查询项
</td>
<td>
<input name="argument" type="checkbox" value="site">地址节点   
<select id="select" name="site">
<%
set Sqlconn = Server.CreateObject("ADODB.Connection")
Sqlconn.Open session("connection")
set SqlRecordSet = Server.CreateObject("ADODB.RecordSet")
strSelect = "select siteId,site from IPS_Site order by siteId"
call SqlRecordSet.Open(strSelect, Sqlconn)

if SqlRecordSet.BOF <> TRUE then SqlRecordSet.MoveFirst()
while SqlRecordSet.EOF <> TRUE
FValue = SqlRecordSet.GetRows(1)
%><option disabled value=<%=fvalue(0,0)%>><%=FValue(1,0)%>
</option>
<%
wend
SqlRecordSet.Close
Sqlconn.Close
%>
</select>
</td>
</tr>
<tr>
<td>
<input name="argument" type="checkbox" value="ipbegin">IP地址段
<table>
<tr>
<td>起始地址:  <input name="ipbegin" type="text"></td>
</tr>
<tr>
<td>结束地址:  <input name="ipend" type="text"></td>
</tr>
</table>
</td>
</tr>

</td>
<tr>
<td>
<input name="argument" type="checkbox" value="ctrlid">调度单号   
<input name="ctrlid" type="text">
</td>
</tr>
<tr>
<td>
<input name="argument" type="checkbox" value="name">业务类型   
<select id="select" name="name">
<%
set Sqlconn = Server.CreateObject("ADODB.Connection")
Sqlconn.Open session("connection")
set SqlRecordSet = Server.CreateObject("ADODB.RecordSet")
strSelect = "select TypeId,name from IPS_type order by TypeId"
call SqlRecordSet.Open(strSelect, Sqlconn)

if SqlRecordSet.BOF <> TRUE then SqlRecordSet.MoveFirst()
while SqlRecordSet.EOF <> TRUE
FValue = SqlRecordSet.GetRows(1)
%><option disabled value=<%=fvalue(0,0)%>><%=FValue(1,0)%>
</option>
<%
wend
SqlRecordSet.Close
Sqlconn.Close
%>
</select>
</td>
</tr>
</td>
</tr>
</table>
<input type="submit" name="submit" value="确定">
</form>
</center>
<Script language="vbscript">

function addItem_onsubmit()
if document.addItem.argument.item(1).checked then
if ipcheck(document.addItem.ipbegin.value)=false then
msgbox("起始地址格式不正确!")
addItem_onsubmit=false
document.addItem.ipbegin.focus
exit function
end if
if ipcheck(document.addItem.ipend.value)=false then
msgbox("结束地址格式不正确!")
addItem_onsubmit=false
document.addItem.ipend.focus
exit function
end if
if is1smallthan2(document.addItem.ipbegin.value,document.addItem.ipend.value)=false then
msgbox("起始地址应该小于等于结束地址!")
addItem_onsubmit=false
document.addItem.ipbegin.focus
exit function
end if
end if
addItem_onsubmit=true
end function

</script>

<%
end sub

sub ipdisaddfirst(ipbegin,ipend,site,ctrlid,name)
dim sqlconn,sqlrecordset,strselect,fvalue,i,records
on error resume next
ipbegin=cdbl(convipstrtoint(ipbegin))
ipend=cdbl(convipstrtoint(ipend))
set Sqlconn = Server.CreateObject("ADODB.Connection")
Sqlconn.Open session("connection")
set SqlRecordSet = Server.CreateObject("ADODB.RecordSet")
strselect ="select ips_data.ctrlid,ips_ipdis.ipid1 from ips_data,ips_ipdis,ips_character where (ips_data.disid1=ips_ipdis.disid or ips_data.disid2=ips_ipdis.disid )"
for each item in Request.form("argument")
if item = "site" then
strselect=strselect+" and IPS_ipdis.siteId="&site&""

end if
if item = "ipbegin" then
strselect=strselect+" and ((ipid1>="&ipbegin&" and ipid1+(255-mask)<="&ipend&") or ((ipid1<="&ipbegin&" and ipid1+(255-mask)>="&ipbegin&") or (ipid1>="&ipbegin&" and ipid1<="&ipend&")))"
end if
if item = "ctrlid" then
strselect=strselect+" and ips_data.ctrlid="&ctrlid&""
end if
if item = "name" then
strselect=strselect+" and (ips_character.typeid="&name&" and ips_character.ctrlid=ips_data.Ctrlid)"
end if

next
strselect =strselect+" order by ips_data.ctrlid"
call SqlRecordSet.Open(strSelect, Sqlconn)
i=2
records=0
%>
<center>
专线工单IP使用分配
<P>
<FORM name=appItem action="ipdisadd.asp?action=add&step=addsecond" method=post>
<TABLE borderColor=#8080ff bgColor=#bcecfa border=1 width=85%>
<TR>
<TD width="25%">选中标志: </td>


<TD width="25%">调度单号: </td>
<TD width="25%">网段起始: </td>
<TD width="25%">广域网或局域网: </td>
<tr>
<%
if sqlrecordset.eof <>true then SqlRecordSet.MoveFirst()
while SqlRecordSet.EOF <> TRUE
records =records + 1
FValue = SqlRecordSet.GetRows(1)
fvalue(1,0)= convipinttostr(cdbl(fvalue(1,0)))
call format_output_radio1(FValue, 0, i, "#fafad2")
wend
SqlRecordSet.Close
Sqlconn.Close
%>
</tr>
<tr>
<TD align=center width="25%"> <INPUT id=submit1 type=submit value=确定 name=add_bt>
</td><td align=center width=25%>   <INPUT id=reset1 type=reset value=清除 name=clear_bt>
</table>
</form>
</TD></TR>
<p>共有<%=records%>条记录</p>
</center>
<%
end sub
%>

整个代码大概就是这样,我要怎么在页面中显示,广域网或局域网呀?
回复
bh2000sh 2002-05-08
select disid ,a='广域网' from A,B where ctrlid="& selectedctrlid&" and disid=disid1
union
select disid ,a='局域网' from A,B where ctrlid="& selectedctrlid&" and disid=disid2
order by disid"
回复
bh2000sh 2002-05-08
select disid ,广域网 from A,B where ctrlid="& selectedctrlid&" and disid=disid1
union
select disid ,局域网 from A,B where ctrlid="& selectedctrlid&" and disid=disid2
order by disid"
回复
liuzxit 2002-05-08
沒有我的份﹐試試而已

strselect="select disid,(case when disid=disid1 then '广域网' else '局域网' end) as net from A,B where ctrlid="& selectedctrlid&" and (disid=disid1 or disid=disid2) order by disid"

然后讀出net就行了吧
回复
twttwt 2002-05-08
希弱呢?
回复
tripofdream 2002-05-08
strselect="select A.disid,'广域网' as netType from A,B where ctrlid="& selectedctrlid&" and disid=disid1 union select A.disid,'局域网' as netType from A,B where ctrlid="& selectedctrlid&" and disid=disid2 order by disid"
回复
liuzxit 2002-05-08
你的數據庫是SQL嗎?如果是那還是老辦法﹐把這句
strselect ="select ips_data.ctrlid,ips_ipdis.ipid1 from ips_data,ips_ipdis,ips_character where (ips_data.disid1=ips_ipdis.disid or ips_data.disid2=ips_ipdis.disid )"
改成
strselect="select ips_data.ctrlid,ips_ipdis.ipid1,(case when disid=disid1 then '广域网' else '局域网' end) as net from A,B where ctrlid="& selectedctrlid&" and (disid=disid1 or disid=disid2) order by disid"

然后在(以下這段我不是很明白﹐不過我想你應該可以作出相應修改吧)
while SqlRecordSet.EOF <> TRUE
records =records + 1
FValue = SqlRecordSet.GetRows(1)
fvalue(1,0)= convipinttostr(cdbl(fvalue(1,0)))
call format_output_radio1(FValue, 0, i, "#fafad2")
wend

這段加入response.write SqlRecordSet("net")不就可以了嗎
回复
liuzxit 2002-05-08
你的數據庫是SQL嗎?如果是那還是老辦法﹐把這句
strselect ="select ips_data.ctrlid,ips_ipdis.ipid1 from ips_data,ips_ipdis,ips_character where (ips_data.disid1=ips_ipdis.disid or ips_data.disid2=ips_ipdis.disid )"
改成
strselect="select ips_data.ctrlid,ips_ipdis.ipid1,(case when disid=disid1 then '广域网' else '局域网' end) as net from A,B where ctrlid="& selectedctrlid&" and (disid=disid1 or disid=disid2) order by disid"

然后在(以下這段我不是很明白﹐不過我想你應該可以作出相應修改吧)
while SqlRecordSet.EOF <> TRUE
records =records + 1
FValue = SqlRecordSet.GetRows(1)
fvalue(1,0)= convipinttostr(cdbl(fvalue(1,0)))
call format_output_radio1(FValue, 0, i, "#fafad2")
wend

這段加入response.write SqlRecordSet("net")不就可以了嗎
回复
julyclyde 2002-05-08
strselect="select A.disid as A_disid,B as B_disid,disid from A,B where ctrlid="& selectedctrlid&" and (disid=disid1 or disid=disid2) order by disid"

读出来以后判断
if rs("a_disid")之类
回复
memgarden 2002-05-08
在线等待中。。。。
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2002-05-08 10:49
社区公告
暂无公告