MS Access 2010与MySQL的ODBC连接
我最近学习了如何使用OBDC连接将表从MySQL链接到MS Access数据库,但存在以下问题:
I've recently learned how to link tables from MySQL to MS access database using OBDC connection but I have the following problem:
我正在构建的应用程序将具有越来越多的表,这些表将达到几千个.我想在MS Access中使用VBA在SQL数据库中创建表.
The application I am building will have increasing number of tables going to a couple of thousands. I want to create tables in the SQL database using VBA in MS Access.
在SQL数据库中创建新表时,如何将这些新表自动链接到Access应用程序?
在我的情况下,这种连接是否是最佳使用方式?
How can I automatically link those new tables to the Access application right when I create them in the SQL db?
Is this sort of connection the best to use in my case?
在创建表的同一例程中,您应该能够将它们链接到您所在的Access-Project中:
In the same routine where you create the table you should be able to link them to the Access-Project you're in like this:
Dim db As DAO.Database
Set db = CurrentDb()
db.TableDefs("yourTable").Connect = _
"ODBC;DSN=yourDSN;SERVER=yourServer;" & _
"PORT=3306;OPTION=12345;" & _
"DATABASE=yourDB;USER=yourUserName;" & _
"PASSWORD=yourPassword"
db.TableDefs("yourTable").RefreshLink
在此处