Foxtable(狐表)用户栏目专家坐堂 → [讨论]关于在select如何中引用变量的问题。


  共有11577人关注过本帖平板打印复制链接

主题:[讨论]关于在select如何中引用变量的问题。

帅哥哟,离线,有人找我吗?
wcs
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1034 积分:7402 威望:0 精华:0 注册:2008/8/31 22:52:00
[讨论]关于在select如何中引用变量的问题。  发帖心情 Post By:2010/8/5 23:22:00 [只看该作者]

有这样几行代码是可以执行的:

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

 

规则本来就是这样的吗?

 

 


 回到顶部