以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [分享]数据导入对比 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=188163) |
-- 作者:tongliaozyr -- 发布时间:2023/9/5 16:15:00 -- [分享]数据导入对比 最近写些与数据导入相关的内容,对比一下手工编码、Filler、Merger 三种方式,用时分别为117秒、90秒、325秒。 一、手工编码 117秒 Dim cmd As New SQLCommand cmd.ConnectionName = sjy Dim dt As DataTable cmd.CommandText = "S ELECT * From {A1_qdk} " dt = cmd.ExecuteReader() For Each dr1 As DataRow In dt.DataRows Dim dr2 As DataRow = DataTables("A1_qdk").AddNew() For i As Integer = 0 To dt.DataCols.Count - 1 dr2(dt.DataCols(i).Name) = dr1(dt.DataCols(i).Name) Next Next 二、Filler 90秒 Dim cmd As New SQLCommand cmd.ConnectionName = sjy Dim dt As DataTable cmd.CommandText = "S ELECT * From {A1_qdk} " dt = cmd.ExecuteReader() Dim f As New Filler f.SourceTable = dt \'指定数据来源 f.SourceCols = "XH,BH,MC,DW,GZRR,JSGZ,ZJBJ" \'指定数据来源列 f.DataTable = DataTables("A1_qdk") \'指定数据接收表 f.DataCols = "XH,BH,MC,DW,GZRR,JSGZ,ZJBJ" \'指定数据接收列 f.Distinct = False f.Fill() \'填充数据 DataTables("A1_qdk").Save 三、Merger 325秒 Dim mg As New Merger mg.SourcePath = dlg.FileName StatusBar.Message1 = ("正在导入清单库...") mg.SourceTableName = "1_qdk" mg.DataTableName = "A1_qdk" mg.Merge() |
-- 作者:有点蓝 -- 发布时间:2023/9/5 16:46:00 -- 屏蔽事件,禁止刷新 Dim cmd As New SQLCommand cmd.ConnectionName = sjy Dim dt As DataTable cmd.CommandText = "S ELECT * From {A1_qdk} " dt = cmd.ExecuteReader() systemready=false DataTables("A1_qdk").StopRedraw For Each dr1 As DataRow In dt.DataRows Dim dr2 As DataRow = DataTables("A1_qdk").AddNew() For i As Integer = 0 To dt.DataCols.Count - 1 dr2(dt.DataCols(i).Name) = dr1(dt.DataCols(i).Name) Next Next DataTables("A1_qdk").ResumeRedraw systemready=true
|
-- 作者:有点蓝 -- 发布时间:2023/9/5 16:46:00 -- 可以看看:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=100317&replyID=&skin=1 |
-- 作者:tongliaozyr -- 发布时间:2023/9/6 7:36:00 -- 谢谢 |
-- 作者:tongliaozyr -- 发布时间:2023/9/6 7:36:00 -- 研究一下 |
-- 作者:y2287958 -- 发布时间:2023/9/6 7:55:00 -- 上个项目文件及数据库,我相信有更快的办法 |