如何通过VB.net以编程方式刷新链接表? [英] How to programatically refresh linked tables through VB.net?

查看:123
本文介绍了如何通过VB.net以编程方式刷新链接表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Access前端,其中有许多通过ODBC链接到MySQL后端的表.我有一个VB.net应用程序,有时会在后端的表中添加列,而发生这种情况时,我需要从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.

我会考虑任何解决方案,只要它不需要重新启动MySQL或Access,并且因为有成百上千的链接,我将只刷新需要刷新的链接(我事先知道).和前端中的表格.

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.

推荐答案

这应该使您入门:

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)

来源: http://bytes .com/topic/visual-basic-net/answers/370859-create-linked-table-access

这篇关于如何通过VB.net以编程方式刷新链接表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆