以文本方式查看主题
- Foxtable(狐表) (http://foxtable.net/bbs/index.asp)
-- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2)
---- 项目卡机 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=78112)
|
-- 作者:sf020cf
-- 发布时间:2015/12/2 11:18:00
-- 项目卡机
在试用中运行 总会有一些异常出现 代码的不严谨 或者数据的格式 都会导致项目卡死在那 在大量数据递交的时即使不出错 在任务管理器中也可能显示窗口不响应
举例说明一下 同一段数据 一样的执行代码 在不同的机子上 一个报错 一个正常
.NET Framework 版本:2.0.50727.5485 Foxtable 版本:2015.11.11.1 错误所在事件:加载[配载订单]失败! 详细错误信息: 日期的语法错误 在查询表达式 \'(1=1 and 出车日期 >= #2015/10/31 星期六# and 出车日期 <= #2015/12/2 星期三#)\' 中。
代码如下:
Dim sd As WinForm.DateTimePicker Dim ed As WinForm.DateTimePicker sd = e.Form.Controls("DateTimePicker1") ed = e.Form.Controls("DateTimePicker2") Dim cpbh As String = e.Form.Controls("项目").Value
Dim filter As String = "1=1" If sd.Value <> Nothing Then filter &= " And 出车日期 >= \'" & sd.value & "\'" End If If ed.Value <> Nothing Then filter &= " And 出车日期 <= \'" & ed.value & "\'" End If If cpbh <> "" Then filter &= " And [项目] Like \'%" & cpbh & "%\' " End If If ed.value = Nothing AndAlso sd.value = Nothing Then filter &= " And 出车日期 = \'" & Date.today & "\'" End If DataTables("配载订单").LoadFilter=filter DataTables("配载订单").Load Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildTree("配载订单", "车牌|司机|项目") trv.Nodes.Insert("所有订单",0)
我把#号改成 \' 又报
.NET Framework 版本:2.0.50727.5485 Foxtable 版本:2015.11.11.1 错误所在事件:加载[配载订单]失败! 详细错误信息: 标准表达式中数据类型不匹配。
这是我第一次自己做开发 好多语法 都不会 期间一直都是红袍版主在无私奉献 在此表示感谢 , 现在也已经提交试用 出于谨慎 公司决定试用之后才购买开发版 可能在众多的用户中 我只不过是一个还未入门的使用者
可我真想好好运用好这样的软件 虽坎坷 路还在
一直也不知道该怎样去规范代码的严谨使项目能正常进行 烦请红袍版主再次帮忙 怎样完善
|
-- 作者:大红袍
-- 发布时间:2015/12/2 11:37:00
--
日期的问题,设置一下其计算机
http://jingyan.baidu.com/article/647f0115925aee7f2148a8b5.html
|
-- 作者:sf020cf
-- 发布时间:2015/12/2 11:54:00
--
我试一下
另外这段代码报未将对象引用至对象实例
Dim Result As DialogResult Result = MessageBox.Show("确定要退出吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) If Result = DialogResult.OK Then Dim dr As DataRow Dim hyzh As String =Forms("主界面").Controls("姓名").Text----------------要读取的是另一个窗口中的控件 ,不是本窗口 hyzh = hyzh.Trim(" ", "登","录","账","号",":","[","]") dr = DataTables("账户管理").Find("[用户账号] = \'" & hyzh & "\' ") dr("用户状态") = False SystemReady = False e.form.Close() Syscmd.Project.Exit(True) SystemReady = True End If
|
-- 作者:大红袍
-- 发布时间:2015/12/2 12:03:00
--
Dim hyzh As String = vars("账号") \'用一个变量在登陆的时候记录账号信息啊 dr = DataTables("账户管理").Find("[用户账号] = \'" & hyzh & "\' ")
If dr is Nothing Then
msgbox("没找到用户")
Else
\'其它操作
End If
|
-- 作者:sf020cf
-- 发布时间:2015/12/2 16:17:00
--
还有个问题 我想请教 就是在出现未响应或者卡死时怎样关闭项目 是否只能在任务管理器中结束 ?
|
-- 作者:大红袍
-- 发布时间:2015/12/2 16:20:00
--
卡死,试试按下alt+F4。不行,就只能结束进程。
|
-- 作者:sf020cf
-- 发布时间:2015/12/2 17:26:00
--
红版 为了不重复导入 引用你以前帮我写的代码 我把导入改为:
Dim dlg As new OpenFileDialog If dlg.ShowDialog = DialogResult.OK Then Dim App As New MSExcel.Application try Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(dlg.FileName) Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets("计划表") Dim Rg As MSExcel.Range = Ws.UsedRange Dim ary = rg.value Tables("配载订单").ResumeRedraw() Tables("配载订单").StopRedraw() Dim nms() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","承运商","司机","车牌","车数","车型","出车日期"} Dim count As Integer = 0 Dim ls As new List(of Row) Dim dic As new Dictionary (Of DataRow, Row) For Each r As Row In Tables("计划表").Rows Dim filter As String = "1=1" For Each dc As String In nms If r.IsNull(dc) Then filter &= " and " & dc & " is null" Else Dim c As Col = Tables("配载订单").Cols(dc) If c.IsNumeric Then filter &= " and " & dc & " = " & r(dc) ElseIf c.IsBoolean Then If r(dc) = True Then filter &= " and " & dc & " = true" Else filter &= " and " & dc & " = false" End If ElseIf c.IsDate Then filter &= " and " & dc & " = #" & r(dc) & "#" Else filter &= " and " & dc & " = \'" & r(dc) & "\'" End If End If Next Dim dr As DataRow = DataTables("配载订单").find(filter) If dr Is Nothing Then ls.Add(r) count += 1 Else dic.add(dr, r) End If Next For n As Integer = 2 To ws.UsedRange.Rows.Count -1 Dim r As Row = Tables("配载订单").AddNew() For m As Integer = 0 To nms.Length - 1 If Tables("配载订单").Cols(nms(m)).IsDate Then Dim d As Date If Date.TryParse(ary(n,m+1), d) r(nms(m)) = d End If Else r(nms(m)) = ary(n,m+1) End If Next Next Tables("配载订单").ResumeRedraw() msgbox("共有 "& count &" 条数据导入" ) catch ex As exception msgbox(ex.message) app.quit End try End If
Tables("配载订单").save e.Form.Controls("提示").Text = "正在导入,请稍后..." Application.DoEvents() e.Form.Controls("提示").Text = "已经导入完成." e.Form.TimerInterval = 5000 e.Form.TimerEnabled = True
点导入时 提示没有名为"计划表"的table 计划表是外部表 要怎样写才能访问到它 另外我不知道我这样套用代码是否可行
|
-- 作者:大红袍
-- 发布时间:2015/12/2 17:31:00
--
上传例子测试。
|
-- 作者:大红袍
-- 发布时间:2015/12/2 17:42:00
--
Dim dlg As new OpenFileDialog If dlg.ShowDialog = DialogResult.OK Then Dim App As New MSExcel.Application try Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(dlg.FileName) Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets("计划表") Dim Rg As MSExcel.Range = Ws.UsedRange Dim ary = rg.value Tables("配载订单").ResumeRedraw() Tables("配载订单").StopRedraw() Dim nms() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","承运商","司机","车牌","车数","车型","出车日期"} Dim count As Integer = 0 Dim ls As new List(of Integer) Dim dic As new Dictionary (Of DataRow, Integer) For n As Integer = 2 To ws.UsedRange.Rows.Count -1 Dim filter As String = "1=1" For m As Integer = 0 To nms.length-1 Dim vl As object = ary(n,m+1) Dim dc As String = nms(m) If vl = Nothing Then filter &= " and " & dc & " is null" Else Dim c As Col = Tables("配载订单").Cols(dc) If c.IsNumeric Then filter &= " and " & dc & " = " & vl ElseIf c.IsBoolean Then If vl = True Then filter &= " and " & dc & " = true" Else filter &= " and " & dc & " = false" End If ElseIf c.IsDate Then filter &= " and " & dc & " = #" & vl & "#" Else filter &= " and " & dc & " = \'" & vl & "\'" End If End If Next Dim dr As DataRow = DataTables("配载订单").find(filter) If dr Is Nothing Then ls.Add(n) count += 1 Else dic.add(dr, n) End If Next For Each n As Integer In ls Dim r As Row = Tables("配载订单").AddNew() For m As Integer = 0 To nms.Length - 1 If Tables("配载订单").Cols(nms(m)).IsDate Then Dim d As Date If Date.TryParse(ary(n,m+1), d) r(nms(m)) = d End If Else r(nms(m)) = ary(n,m+1) End If Next Next Tables("配载订单").ResumeRedraw() msgbox("共有 "& count &" 条数据导入" ) catch ex As exception msgbox(ex.message) app.quit End try End If
Tables("配载订单").save e.Form.Controls("提示").Text = "正在导入,请稍后..." Application.DoEvents() e.Form.Controls("提示").Text = "已经导入完成." e.Form.TimerInterval = 5000 e.Form.TimerEnabled = True
|
-- 作者:sf020cf
-- 发布时间:2015/12/2 18:04:00
--
报错 该字符串未被识别为datatime
|