以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]怎样同时导入数据库内的全部表? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=91870) |
||||
-- 作者:wusim -- 发布时间:2016/10/20 16:46:00 -- [求助]怎样同时导入数据库内的全部表? 怎样同时导入数据库内的全部表?(包括基本信息表、安全保护装置、 尺寸测量、零部件、受力结构件)以下代码怎样改?
代码见附件
|
||||
-- 作者:有点蓝 -- 发布时间:2016/10/20 17:07:00 -- Dim dlg As new OpenFileDialog dlg.Filter = "数据库|*.mdb" If dlg.ShowDialog = DialogResult.OK Then Dim dict As new Dictionary(of String,String) dict.Add("基本信息表","出厂编号") dict.Add("XXX表","XX编号") Connections.Add("test","Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dlg.FileName & ";Persist Security Info=False") Dim cmd As New SQLCommand cmd.C Dim dt As DataTable Dim lst As List(Of String) lst = Connections("test").GetTableNames For Each nm As String In lst If dict.ContainsKey(nm) Dim bh As String = dict(nm) cmd.CommandText = "SeLECT * From {" & nm & "}" dt = cmd.ExecuteReader() For Each dr As DataRow In dt.DataRows If DataTables(nm).Find(bh & "= \'" & dr(bh) & "\'") Is Nothing Then Dim nr As DataRow = DataTables(nm).AddNew() For Each dc As DataCol In dt.DataCols nr(dc.name) = dr(dc.name) Next End If Next End If Next Connections.Delete("test") End If |
||||
-- 作者:wusim -- 发布时间:2016/10/20 19:42:00 -- 显示错误
cmd.C |
||||
-- 作者:有点蓝 -- 发布时间:2016/10/20 20:29:00 -- 改回你自己的设置数据源代码,对比你的附件代码,发帖时有些关键字被论坛过滤了 |
||||
-- 作者:wusim -- 发布时间:2016/10/20 20:47:00 -- ok 谢谢老师 |