读书人

关于vb与sql查询的有关问题

发布时间: 2012-04-24 14:15:38 作者: rapoo

关于vb与sql查询的问题
查询语言:
Set rs = cn.Execute("select 站名 from tabAddress where 区站号 not in (select 区站号 from tabTimeData where 入库时间>'2011-09-27')")
如查询结果为:站名1,站名2,站名3,请问怎么把查询结果赋值给变量,或把查询结果写入.TXT文件,再用VB读.TXT,谢谢了!

[解决办法]
Set rs = cn.Execute("select 站名 from tabAddress where 区站号 not in (select 区站号 from tabTimeData where 入库时间>'2011-09-27')")
这个应该有问题吧?
Set rs = cn.Execute("select 站名 from tabAddress where 区站号 not in (select 区站号 from tabTimeData where 入库时间>#2011-09-27#)")

2:
dim s as string
with rs
if .recordcount>0 then
.movefirst
while not .eof
s=.fields("站名")
select case s
case "站名1"
text1=。。。
case "站名2"
text2=....
case "站名3"
text3=.....

........
end select
.movenext
wend
end if
end with

读书人网 >VB

热点推荐