以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 用数据库组件方法导入数据时的问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=186495) |
-- 作者:HANZHIGANG -- 发布时间:2023/5/6 20:28:00 -- 用数据库组件方法导入数据时的问题 Dim st1 As Date = Date.Now() DataTables(maintable.Name).RemoveFor("") Dim dlg As New OpenFileDialog dlg.Filter = "Excel文件|*.xls;*.xlsx" If dlg.ShowDialog = DialogResult.Ok Then Dim mg As New Merger mg.SourcePath = dlg.FileName mg.Format = "excel" mg.SourceTableName = MainTable.name & "$" mg.DataTableName = maintable.Name mg.Merge() If MainTable.Rows.Count > 0 Then Dim Result As DialogResult Result = MessageBox.Show("确定导入数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If Result = DialogResult.Yes Then Dim db = HySql.DataBaseFactory.CreateDatabase() db.BulkInsert(DataTables(maintable.name).BaseTable, maintable.name) Dim dt As Date = Date.Now Dim sp As New TimeSpan(0, 0, 30) Dim dt2 As Date = dt - sp DataTables(maintable.Name).RemoveFor("") DataTables(maintable.Name).LoadFilter = "[操作员] = \'" & user.Name & "\' and [操作日期] Between \'" & dt2 & "\' And \'" & dt & "\'" DataTables(maintable.Name).Load() Else DataTables(maintable.Name).RemoveFor("") End If End If End If MessageBox.Show("耗时: " & (Date.Now - st1).TotalSeconds & "秒") 用以上代码合并数据,出现如下错误提示: .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2022.8.18.1 错误所在事件:窗口,客户查询,导入,Click 详细错误信息: 从索引 0 处开始,初始化字符串的格式不符合规范。 |
-- 作者:HANZHIGANG -- 发布时间:2023/5/6 20:47:00 -- 和表中添加的两个临时列有关吗?我合并前把这两列删除,再进行合并处理,但还是这个提示 [此贴子已经被作者于2023/5/6 21:04:51编辑过]
|
-- 作者:有点蓝 -- 发布时间:2023/5/7 20:44:00 -- 调试看是哪一句代码执行后出错 |
-- 作者:HANZHIGANG -- 发布时间:2023/5/8 8:48:00 -- Dim db = HySql.DataBaseFactory.CreateDatabase() db.BulkInsert(DataTables(maintable.name).BaseTable, maintable.name) 这句
|
-- 作者:有点蓝 -- 发布时间:2023/5/8 8:59:00 -- 绑定窗口后Foxtable会自动增加一些临时列,都要去掉 Dim dtCopy As System.Data.DataTable = DataTables(maintable.name).BaseTable.Copy dtCopy.Columns.Remove("_Locked") dtCopy.Columns.Remove("System_Sort_Temporary") dtCopy.Columns.Remove("System_Filter_Temporary") dtCopy.Columns.Remove("System_Filter_Unique") db.BulkInsert(dtCopy, maintable.name) |