这是可以正常执行的QueryBuilder,其中:"会计凭证查询"表不需要在狐表中新建,也不是数据源 "会计数据库"某个表,它是自己命名的用于存放Select查询结果的表,表字段属性与源表[z_tablqpz] 一模一样。查询语句有点长,它合并了三个结构相同的表,一般不需这样搞的。
Dim q As new QueryBuilder
q.TableName = "会计凭证查询"
q.C
dim s as string
s = "select * from [z_tablqpz] where sszt = "&vars("账套")&" and cast(cast(pzrqn as char(4))+'-'+cast(pzrqy as char(2))+'-'+cast(pzrqr as char(2)) as datetime) between '"&vars("开始日期")&"' and '"&vars("结束日期")&"'"
s = s & "union all select * from [z_tabdqpz] where sszt = "&vars("账套")&" and cast(cast(pzrqn as char(4))+'-'+cast(pzrqy as char(2))+'-'+cast(pzrqr as char(2)) as datetime) between '"&vars("开始日期")&"' and '"&vars("结束日期")&"'"
s = s & "union all select * from [z_tabxqpz] where sszt = "&vars("账套")&" and cast(cast(pzrqn as char(4))+'-'+cast(pzrqy as char(2))+'-'+cast(pzrqr as char(2)) as datetime) between '"&vars("开始日期")&"' and '"&vars("结束日期")&"'"
s = s & "order by pzrqn,pzrqy,pzlx,pzdm,flxh"
q.SelectString = s
q.Build