Foxtable(狐表)用户栏目专家坐堂 → [求助]


  共有8372人关注过本帖树形打印复制链接

主题:[求助]

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


加好友 发短信
等级:婴狐 帖子:4 积分:124 威望:0 精华:0 注册:2012/3/9 14:50:00
[求助]  发帖心情 Post By:2012/4/26 9:19:00 [显示全部帖子]

 我 在项目Initialize事件中,设置Var全局变量

代码

Dim KJQM As String

Dim d As Date = Date.ToDay  '#3/25/2012#

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  '#3/25/2012#

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

急切得到答复!


 回到顶部