以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助] (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=19053) |
-- 作者:SHIMSMS -- 发布时间:2012/4/26 9:32:00 -- [求助] 我 在项目Initialize事件中,设置Var全局变量 代码 : Dim KJQM
As String Dim d
As Date = Date.ToDay \'# Dim kj
As String = CStr(d.Year) Dim qj
As String = CStr(d.Month) qj = qj.PadLeft(2,"0") KJQM = kj & qj
Vars.Add("KJQS",Gettype(String)," ") Vars("KJQS") = "’"& KJQM &"’"
返回 变量 = ‘201204’( 在命令窗口Output.Show(Vars("KJQS"))验证准确)。 然后应用 : 在一个共有窗口的表属性中设置,表类型SQLQuery,数据源(SQL Server), Select 语句 : Select LH,SUM(UL) As UL,SUM(UL*DJ) As JE,LY,KJQJ FROM WL99
WHERE KJQJ = \'" & Vars("KJQS") & "\' GROUP BY
LH,LY,KJQJ ORDER BY LH 或将条件表达式写为WHERE
KJQJ = \' & Vars("KJQS") & \' 其结果都返回一空表。 如果将代码改写为: Select LH,SUM(UL) As UL,SUM(UL*DJ) As JE,LY,KJQJ FROM WL99
WHERE KJQJ = ‘201204’ GROUP BY
LH,LY,KJQJ ORDER BY LH 条件表达式直接使用值 ‘201204’,而不是全局变量的表达式, 结果即按条件 KJQJ = ‘201204’ 显示所有记录 。 我又在“全局代码”菜单中设置:Public KJQX As String 全局变量 KJQX 接着在项目Initialize事件中设置代码: Dim KJQM
As String Dim d
As Date = Date.ToDay \'# Dim kj
As String = CStr(d.Year) Dim qj
As String = CStr(d.Month) qj = qj.PadLeft(2,"0") KJQM = kj & qj KJQX = "\'" &
KJQM & "\'" ( 或者在表窗口AfterLoad 事件中设置如上代码 ) 将表属性中 Select 改写为: Select LH,SUM(UL) As UL,SUM(UL*DJ) As JE,LY,KJQJ FROM WL99
WHERE KJQJ = ‘& KJQX &’ GROUP BY
LH,LY,KJQJ ORDER BY LH 返回结果仍然是一空表
请教在SQL语句中如何写条件表达式? 在实际应用模块中要用到此类的全局变量之处很多, 我正在编写一应用软件,成功后向你们购买一套 FoxTable 软件。 回复邮箱:1139146080@QQ.com 急切得到答复! |
-- 作者:狐狸爸爸 -- 发布时间:2012/4/26 9:39:00 -- 请不要重复发帖,你的问题已经回复,看原帖的三楼:
http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=19052
|