以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  加载当天的数据  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=131463)

--  作者:恒隆君
--  发布时间:2019/2/26 23:01:00
--  加载当天的数据
SQL server 数据库
为什么明明有入库日期 = 2019-2-26 的行。
但就是不加载。

如果filter 设为 "入库日期 <= \'2019-2-26\'
也是不能加载2019-2-26,必须要设成  "入库日期 <= \'2019-2-27\'

Dim dt As DataTable = DataTables("配件入库明细")
dt.LoadFilter = "入库日期 = \'" & Date.today & "\'"
msgbox(Date.today)
dt.Load()

--  作者:恒隆君
--  发布时间:2019/2/26 23:05:00
--  

如查设一个全局代码 today.

怎样保持不重启系统

也是最新的日期。




 \'读取SQL服务器时间

            Dim today As Date

            Dim cmd As New SQLCommand

            cmd.ConnectionName = cn

            cmd.CommandText = "Select GetDate()"

            Today = cmd.ExecuteScalar()



--  作者:有点蓝
--  发布时间:2019/2/26 23:21:00
--  
日期值有时分秒,要这样用

dt.LoadFilter = "入库日期 >= \'" & Date.today & "\' and 入库日期 < \'" & Date.today.adddays(1) & "\'"

--  作者:恒隆君
--  发布时间:2019/2/27 0:36:00
--  
不可以取日期里的 日期

加载当天的数据,
以前一直都没有这个问题。

关键是窗口里的筛选代码不知如何改。

Dim bjf() As String = {" ="," = "," like "," = "," = "," = ",">=","<=",">=","<="}
Dim fds() As String = {"仓库名称","入库原因","配件名称","配件代码","供应商名称","送货单号","入库日期","入库日期","数量","数量"}
Dim tpf() As String = {"","","%","","","","","","",""}
Dim filter As String
For i As Integer = 0 To nms.Length - 1
    If e.Form.Controls(nms(i)).text <> Nothing Then
        If filter > "" Then
            filter = filter & " And "
        End If
        filter = filter & fds(i) & bjf(i) & sps(i) & tpf(i) & e.Form.Controls(nms(i)).value &tpf(i) & sps(i)
\' MessageBox.show(filter)
    End If
Next
DataTables("配件入库明细").LoadFilter = filter
DataTables("配件入库明细").Load()


--  作者:有点甜
--  发布时间:2019/2/27 9:29:00
--  

Dim bjf() As String = {" ="," = "," like "," = "," = "," = ",">=","<=",">=","<="}
Dim fds() As String = {"仓库名称","入库原因","配件名称","配件代码","供应商名称","送货单号","入库日期","入库日期","数量","数量"}
Dim tpf() As String = {"","","%","","","","","","",""}
Dim filter As String
For i As Integer = 0 To nms.Length - 1
    If e.Form.Controls(nms(i)).text <> Nothing Then
        If filter > "" Then
            filter = filter & " And "
        End If
        If fds(i) = "入库日期" AndAlso bjf(i) = "<=" Then
            filter = filter & fds(i) & bjf(i) & sps(i) & tpf(i) & e.Form.Controls(nms(i)).value.adddays(1) &tpf(i) & sps(i)
        Else
            filter = filter & fds(i) & bjf(i) & sps(i) & tpf(i) & e.Form.Controls(nms(i)).value &tpf(i) & sps(i)
        End If

        MessageBox.show(filter)
    End If
Next
DataTables("配件入库明细").LoadFilter = filter
DataTables("配件入库明细").Load()