有这样几行代码是可以执行的:
Dim q As new QueryBuilder
q.TableName = "会计凭证查询"
q.C
dim s as string
s = "select * from [z_tabdqpz] where sszt = "& e.Form.Controls("账套编号").Value &"and pzrqn = "& e.Form.Controls("账套年度").Value
s = s & "union all select * from [z_tabxqpz] where sszt = "& e.Form.Controls("账套编号").Value &"and pzrqn = "& e.Form.Controls("账套年度").Value
s = s & "union all select * from [z_tablqpz] where sszt = "& e.Form.Controls("账套编号").Value &"and pzrqn = "& e.Form.Controls("账套年度").Value
s = s & "order by pzrqn,pzrqy,pzlx,pzdm,flxh"
q.SelectString = s
q.Build
但是我用定义的变量写入select中,就不能执行了:
Dim ztnd As WinForm.TextBox = e.Form.Controls("账套年度").Value
Dim ztbh As WinForm.TextBox = e.Form.Controls("账套编号").Value
Dim q As new QueryBuilder
q.TableName = "会计凭证查询"
q.C
dim s as string
s = "select * from [z_tabdqpz] where sszt = "& ztbh &"and pzrqn = "& ztnd
s = s & "union all select * from [z_tabxqpz] where sszt = "& ztbh &"and pzrqn = ztnd
s = s & "union all select * from [z_tablqpz] where sszt = "& ztbh &"and pzrqn = ztnd
s = s & "order by pzrqn,pzrqy,pzlx,pzdm,flxh"
q.SelectString = s
q.Build
规则本来就是这样的吗?