以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  为什么概率性闪退  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=126917)

--  作者:jeffic
--  发布时间:2018/10/30 19:19:00
--  为什么概率性闪退

有个窗口,里面有个统计外部数据库的临时表 有个统计按钮,一案会时不时的闪退窗口

按钮代码如下

DataTables("今日订单").Save()
Dim mx As WinForm.CheckBox = e.Form.Controls("CheckBox1")
Dim syzs As WinForm.CheckBox = e.Form.Controls("CheckBox2")
Dim yj As WinForm.CheckBox = e.Form.Controls("CheckBox3")
Dim ks As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1")
Dim js As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker2")
Dim zs As WinForm.ComboBox = e.Form.Controls("ComboBox1")

If mx.Checked = False And syzs.Checked =False And zs.Value = ""  Then
    MessageBox.Show("分销名, 查看明细,所有分销至少选择一个")
    Return
End If
Dim kssj As Date = ks.Value
Dim jssj As Date = js.Value
Dim g As New GroupTableBuilder("统计表1", DataTables("今日订单"))
If yj.Checked = False Then
   
    Dim TIME As String="[录入时间] >= #"& kssj &"# And [录入时间] <= #"& JSSJ &"#"
    Dim F As String
    If ZS.Text="" Then
        F = TIME
    Else
        F= "[录入时间] >= #"& kssj &"# And [录入时间] <= #"& JSSJ &"# AND [直属名] = \'"& zs.text &"\'"
        g.Groups.AddDef("代理名")
    End If
    g.Filter =F
   
    If syzs.Checked = True Then
        g.Groups.AddDef("代理名")
    End If
   
    If mx.Checked = True Then
        g.Groups.AddDef("表单名")
        g.Totals.AddDef("数量")
    End If
   
    g.Totals.AddDef("分销金额")
   g.Totals.AddDef("直属金额")
    g.Totals.AddDef("邮费")
    g.Totals.AddDef("订单数")
    g.Totals.AddDef("返利")
   
    g.FromServer = True
    g.VerticalTotal = True \'自动垂直汇总
    g.Build()
Else
   
    Dim TIME As String="[录入时间] >= #"& kssj &"# And [录入时间] <= #"& JSSJ &"#"
    Dim F As String
    If ZS.Text="" Then
        F = TIME
    Else
        F= "[录入时间] >= #"& kssj &"# And [录入时间] <= #"& JSSJ &"# AND [直属名] = \'"& zs.text &"\'"
        g.Groups.AddDef("代理名")
    End If
    g.Filter ="\'"& F &"\' and [是否算业绩]=True"
   
    If syzs.Checked = True Then
        g.Groups.AddDef("代理名")
    End If
   
    If mx.Checked = True Then
        g.Groups.AddDef("表单名")
        g.Totals.AddDef("数量")
    End If
   
    g.Totals.AddDef("直属金额","实际业绩")
    g.Totals.AddDef("邮费")
    g.Totals.AddDef("订单数")
    g.Totals.AddDef("返利")
   
    g.FromServer = True
    g.VerticalTotal = True \'自动垂直汇总
    g.Build()
   
End If
Tables("统计_Table1").DataSource = g.BuildDataSource()

 


图片点击可在新窗口打开查看此主题相关图片如下:捕获.png
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2018/10/30 20:32:00
--  
1、去掉上面代码中的2个:g.Build()

2、

g.Filter ="\'"& F &"\' and [是否算业绩]=True"

改为

g.Filter = F &" and [是否算业绩]=True"

--  作者:jeffic
--  发布时间:2018/10/30 21:32:00
--  

好的,我试一下   谢谢老师!