以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  DateTimePicker的ValueChanged  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=100145)

--  作者:huhu
--  发布时间:2017/5/5 15:00:00
--  DateTimePicker的ValueChanged
DateTimePicker1的ValueChanged代码:   提示#附近有语法错误
Dim sj As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1")
Dim jssj As Date = sj.Value
Dim fhdh As WinForm.ComboBox = e.Form.Controls("ComboBox13")
Dim hydh As WinForm.ComboBox = e.Form.Controls("ComboBox03")
If fhdh.text > "" Then
    DataTables("库存明细表").LoadFilter = "出库完成时间 > #" & jssj & "# And 出库完成时间 < #" & jssj.adddays(1) & "# And U8发货单号 = \'" & fhdh.text & "\'"
    DataTables("库存明细表").Load
ElseIf hydh.text > "" Then
    DataTables("库存明细表").LoadFilter = "出库完成时间 > #" & jssj & "# And 出库完成时间 < #" & jssj.adddays(1) & "# And U8发货单号 = \'" & hydh.text & "\'"
    DataTables("库存明细表").Load
End If

--  作者:有点色
--  发布时间:2017/5/5 15:03:00
--  

 如果你的表是外部表,你的数据库是sqlserver,你要把#改成单引号\'

 

 如果还报错,就是日期格式问题,AfterOpenProject写代码

 

Dim cd As System.Globalization.DateTimeFormatInfo = System.Globalization.DateTimeFormatInfo.CurrentInfo
cd.ShortDatePattern = "yyyy年MM月dd日"
Dim DateInfo As System.Reflection.FieldInfo = cd.Gettype.GetField("generalLongTimePattern", System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.Instance)
If  DateInfo IsNot Nothing Then
    DateInfo.SetValue(cd, "yyyy-MM-dd HH:mm:ss")
End If