I wrote a ADO.NET 3.5 based program that is using a Jet database. That Jet
database has linked tables to another Jet database on the box. I discovered
that opening the jet database with an oledbconnection sometimes had issues
with the links being wrong, so I stole a code snippet that relinks the
databases in DAO.
This code snippet works the first time, but if I close and open another
database of like type (with linked tables), the code to relink the tables
fails. It happens on the second time, doesnt matter which database is opened
first
Here's the DAO snippet
Dim TheEngine As New dao.DBEngine
Dim TheDatabase As dao.Database
TheEngine.SystemDB = Get_Database_Location(Installation) +
"SYSTEM.MDA"
TheDatabase =
TheEngine.OpenDatabase(Get_Database_Locatio(Installation)+ DatabaseName)
For Each tdf As dao.TableDef In TheDatabase.TableDefs
If tdf.Connect <> "" Then
MsgBox(tdf.Connect + tdf.Name)
If Right(tdf.Connect, 10).ToUpper = "MWPSYS.MDB" Then
tdf.Connect = ";DATABASE=" +
Get_Database_Location(Installation) + "MWPSYS.MDB"
tdf.RefreshLink()
End If
End If
Next
TheDatabase.Close()
End Sub
That code snippet executes before the database is opened with an
oledbconnection. When switching to a second database, I close the
oledbconnection, and try to execute this snippet on the second database. It
fails with an error that makes no sense (referring to a table that doesn't
even exist)
I was thinking that perhaps the issue is mixing dao and oledbconenctions
in the same application?