VB.net 2010 - 创建Access数据库 [英] VB.net 2010 - Create Access database
问题描述
我一直在研究一个运行在多个工作站上的系统,服务器创建一个由远程系统处理的访问数据库。
我有数据库/ table创建工作,问题来自创建完成后,服务器保持数据库打开,这意味着数据库无法移动到远程系统。
下面是重现相同问题的测试代码。
I've been working on a system that runs across multiple workstations, the server creates an access database that is processed by remote systems.
I have the database/table creation working, problem comes when the creation is complete, the server keeps the database opened which means the database can't be moved to the remote system.
Below is test code that will reproduce the same issue.
Dim Database As String = "C:\Database.mdb"
Do
Try
If File.Exists(Database) Then File.Delete(Database)
Dim cat As New ADOX.Catalog()
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Database)
cat = Nothing
Catch ex As Exception
End Try
Sleep(5) ' Code not displayed but does not put the app to sleep just a delay with application.doevents...
Loop
检查是否有我遗漏的东西,或者是否有其他方法可以创建和发布数据库....?
Checking to see if there is something I'm missing or if there is another way to create and release the database....?
推荐答案
我相信你应该关闭你与DB的连接,因为它仍然打开。
I believe you should close your connection to the DB, because it's still opened.
cat.ActiveConnection.Close
详细了解目录此处。 此处是一个应该如何工作的示例有连接(不要忘记关闭它们)。
Read more about Catalog here. Here is an example how one should work with connections (do not forget to close them).
这篇关于VB.net 2010 - 创建Access数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!