初始连接本地的数据库 A (有10个表) 希望 后面 加载两个数据源 B(B中7个表)和C (C中3个表) ,B C 和A中结构完全一致 就是数量进行了拆分
Dim s As String =""
'遍历当前属于此数据源的表
For Each dt As DataTable In DataTables
If dt.C Then
s += "|" & dt.name
End If
Next
s = s.Trim("|")
'卸载表
DataTables.Unload(s)
Connections.Delete("mtsever")
'删除数据源
看到表全部卸载了,下面就没法加载进去,不知道是不是思路和做法有问题?
Dim str As String= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ProjectPath
Dim str2 As String=".mdb;Persist Security Info=False"
Dim strnams() As String={"mt2sever","gtsever"}
For Each strnam As String In strnams
If Connections.Contains(strnam)=False Then
Connections.Add(strnam,str & strnam & str2)
End If
Next
For Each cn As Connection In Connections
Dim lst As List(Of String)= Connections(cn.Name).GetTableNames
For Each nm As String In lst
If DataTables.Contains(nm)=False Then
DataTables.load(nm)
End If
Next
Next
'