How to programatically refresh linked tables through VB.net?
I have an Access frontend with a lot of tables linked through ODBC to a MySQL backend. I have a VB.net application that sometimes adds columns to the tables in the backend, and when that happens, I need to refresh the link to the table in the frontend from the VB.net app to show the new columns.
I'll consider just 开发者_开发百科about any solution as long as it doesn't require restarting MySQL or Access, and will allow me to refresh only the links I need to refresh (which I know in advance) as there are hundreds of links and tables in the frontend.
This should get you started:
Dim Con As New ADODB.Connection
Dim Cat As New ADOX.Catalog
Dim tbl As New ADOX.Table
Con.Open(m_sAccessDbPath)
Cat.ActiveConnection = Con
' Name the new Table and set its ParentCatalog property
' to the open Catalog to allow access to the Properties
' collection.
tbl.Name = m_sAccessDbTableName
tbl.ParentCatalog = Cat
' Set the properties to create the link.
tbl.Properties("Jet OLEDB:Create Link").Value = True
tbl.Properties("Jet OLEDB:Link Provider String").Value = RemoteDbPath
tbl.Properties("Jet OLEDB:Remote Table Name").Value = RemoteTableName
' Append the table to the Tables collection.
Cat.Tables.Append(tbl)
Source: http://bytes.com/topic/visual-basic-net/answers/370859-create-linked-table-access
精彩评论