以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]窗口表不能实现查询功能  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=91676)

--  作者:qscwdvefb
--  发布时间:2016/10/16 22:52:00
--  [求助]窗口表不能实现查询功能
我这个系统是连接外部数据源,在没有录入大量数据和弄好分页加载之前我的窗口表的查询是可以用的,但是之后就不能用了,出现了以下错误:

.NET Framework 版本:2.0.50727.5485
Foxtable 版本:2016.7.29.1
错误所在事件:窗口,户明细账缴费查询,Button1,Click
详细错误信息:
未将对象引用设置到对象的实例。

请问是什么原因?如何解决它?


--  作者:狐狸爸爸
--  发布时间:2016/10/17 8:02:00
--  
1、问题的时候,你要贴出代码,别人才能帮助到你,上面的错误已经告诉您是button1的click事件有误,应该贴出这个事件的代码。
2、可以看看:


--  作者:qscwdvefb
--  发布时间:2016/10/17 10:42:00
--  
Forms("缴费户卡").Open
Dim dr1 As DataRow = DataTables("T246").Find("[F4411] Is Not Null", "F4411", 0)
Dim dr2 As DataRow = DataTables("T246").Find("[F4411] Is Not Null", "F4411 Desc",0)
Dim d1 As Date
Dim d2 As Date
Dim drl0 As DataRow
Dim dt1 As Date =dr1("F4411")
Dim dt2 As Date =dr2("F4411")



Dim val1 As New List (of String)
val1= DataTables("T246").GetValues("F4386")
Dim d As Integer = dt2.Year -dt1.Year
Dim j As Integer = 0
Dim drl As New List (of DataRow)
Dim filter As String =""
For i As Integer = 0 To d
    d1 = New Date(dt1.Year+i-1,11,15) \'取得该年的第一天
    d2 = new Date(dt1.Year+i,11,15) \'取得该年的最后一天
    For Each val As String In val1
        drl0 = DataTables("T246").Find("[F4411] >= #" & d1 & "# And [F4411] <= #" & d2 & "# And [F4386] =\'" & val & "\'","F4411 Desc",0)
        If drl0 IsNot Nothing Then
            drl.add(drl0)
            j= j+1
        End If
    Next
Next
For k As Integer = 0 To j-1
    If Filter > ""  Then
        Filter = Filter & " or "
    End If
    filter = filter & "[T246Id] = \'" &  drl(k)("T246Id")  &  "\'"
Next

Dim filter1 As String = ""

With e.Form.Controls("comboBox1")
    If .Value IsNot Nothing Then
        filter1 = "[F5319] Like \'*" & .Value & "*\'"
    End If
End With
With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If filter1 > "" Then
            filter1 = filter1 & " And "
        End If
        filter1 = filter1 & "[F4362] Like \'*" & .Value & "*\'"
    End If
End With
With e.Form.Controls("TextBox2")
    If .Value IsNot Nothing Then
        If filter1 >"" Then
            filter1 = filter1 & " And "
        End If
        filter1 = filter1 & "[F4387]  Like \'*" & .Value & "*\'"
    End If
End With
With e.Form.Controls("TextBox3")
    If .Value IsNot Nothing Then
        If filter1 >"" Then
            filter1 = filter1 & " And "
        End If
        filter1 = filter1 & "[F4386]Like \'*" & .Value & "*\'"
    End If
End With
With e.Form.Controls("TextBox4")
    If .Value IsNot Nothing Then
        If filter1 >"" Then
            filter1 = filter1 & " And "
        End If
        filter1 = filter1 & "[F4385] Like \'*" & .Value & "*\'"
    End If
End With
With e.Form.Controls("TextBox5")
    If .Value IsNot Nothing Then
        If filter1 >"" Then
            filter1 = filter1 & " And "
        End If
        filter1 = filter1 & "[F4384]Like \'*" & .Value & "*\'"
    End If
End With
If filter1 > "" Then
    filter1 = filter1 & " and"
End If
If filter > "" Then
filter = "( " & filter & " ) "
End If
filter1 = filter1 & filter

Forms("缴费户卡").Controls("Table1").Table.filter = filter1

我看不出那里有问题图片点击可在新窗口打开查看。在弄分页加载前这段代码没有问题。。。

--  作者:qscwdvefb
--  发布时间:2016/10/17 10:55:00
--  
话说把这段代码改为SQL语句是不是就可以在后台上对所有数据进行查询了?
--  作者:有点蓝
--  发布时间:2016/10/17 11:23:00
--  
Forms("缴费户卡").Open
Dim dr1 As DataRow = DataTables("T246").Find("[F4411] Is Not Null", "F4411", 0)
Dim dr2 As DataRow = DataTables("T246").Find("[F4411] Is Not Null", "F4411 Desc",0)
If dr1 Is Nothing OrElse dr2 Is Nothing Then Return
......其它代码

回4楼,是的

--  作者:qscwdvefb
--  发布时间:2016/10/17 11:36:00
--  
其它代码是什么呢?图片点击可在新窗口打开查看
--  作者:qscwdvefb
--  发布时间:2016/10/17 11:41:00
--  
还有,用SQL从后台查询一万多行数据会不会花很多时间?
--  作者:有点蓝
--  发布时间:2016/10/17 11:49:00
--  
3楼原来的其它代码

Forms("缴费户卡").Open
Dim dr1 As DataRow = DataTables("T246").Find("[F4411] Is Not Null", "F4411", 0)
Dim dr2 As DataRow = DataTables("T246").Find("[F4411] Is Not Null", "F4411 Desc",0)
If dr1 Is Nothing OrElse dr2 Is Nothing Then Return

Dim d1 As Date
Dim d2 As Date
Dim drl0 As DataRow
Dim dt1 As Date =dr1("F4411")
Dim dt2 As Date =dr2("F4411")
......

--  作者:qscwdvefb
--  发布时间:2016/10/17 12:01:00
--  
为什么加上If dr1 Is Nothing OrElse dr2 Is Nothing Then Return
就可以解决呢?
什么原因?

--  作者:有点蓝
--  发布时间:2016/10/17 12:05:00
--  
http://www.foxtable.com/webhelp/scr/0396.htm

一旦订单表并不存在订购数量超过1000的订单,那么Find方法返回Nothing,导致后续代码运行出错。