473,322 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Disconnecting from a MS Access database using VB.Net - ADOX ldb issue

Hi,

I have been working on this piece of code which lists all tables in a MS Access database (including linked tables) and converts them to a DataTable with a pre-defined format. I use ADOX and Visual Basic .NET

It all works fine, except when I need to close the connection. I have read various forums on the topic, and the suggested solutions only seem to work as long as I do not try to access the ADOX.Table properties ("Jet OLEDB:Link Datasource" and "Jet OLEDB:Remote Table Name"). Because my code calls these properties, I am unable to completely close the connection to my Access database (the .ldb file stays there until I shut down the application).

I have tried implementing the solutions suggested in http://www.themssforum.com/Ado/file-stays/, http://www.pcreview.co.uk/forums/thread-1245554-2.php and http://www.thescripts.com/forum/thread559491.html without success.

I don't know where else to look for...

Thanks !


Manuel




Below is my complete code:

Dim adoCon As New ADODB.Connection
Dim adoCat As New ADOX.Catalog
Dim adoTbl As New ADOX.Table

'Connect to database
adoCon.Open("Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;OLE DB Services=-4;Data Source = C:\Test.mdb")
adoCat.ActiveConnection = adoCon


Dim TblList As New System.Data.DataTable
Dim dc As New System.Data.DataColumn
dc.ColumnName = "TblName"
dc.DataType = GetType(String)
TblList.Columns.Add(dc)
dc = New DataColumn
dc.ColumnName = "TblType"
dc.DataType = GetType(String)
TblList.Columns.Add(dc)
dc = New DataColumn
dc.ColumnName = "LinkDBPath"
dc.DataType = GetType(String)
TblList.Columns.Add(dc)
dc = New DataColumn
dc.ColumnName = "LinkDBTable"
dc.DataType = GetType(String)
TblList.Columns.Add(dc)
dc.Dispose()
dc = Nothing


Dim dr As DataRow = TblList.NewRow()

'List links
For Each adoTbl In adoCat.Tables
If adoTbl.Type = "LINK" Or adoTbl.Type = "TABLE" Then
dr("TblType") = adoTbl.Type
dr("TblName") = adoTbl.Name
dr("LinkDBPath") = adoTbl.Properties("Jet OLEDB:Link Datasource").Value
dr("LinkDBTable") = adoTbl.Properties("Jet OLEDB:Remote Table Name").Value
TblList.Rows.Add(dr)
adoTbl.Properties.Refresh()
dr = TblList.NewRow()
End If

Next


dr = Nothing
adoTbl = Nothing
adoCat.ActiveConnection.Close()
adoCat = Nothing
Dec 27 '07 #1
0 1645

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Kenny Ashton | last post by:
Can anyone tell me how to overcome my 'permissions problems' every time I upload a new database to my ISP's server. I have a folder, specially created for me by the ISP, where I can upload new...
10
by: Job Lot | last post by:
Is there any way to programmatically link access tables using vb.net
41
by: Ruby Tuesday | last post by:
Hi, I was wondering if expert can give me some lite to convert my word table into access database. Note: within each cell of my word table(s), some has multi-line data in it. In addition, there...
6
by: Null Reference | last post by:
Anybody here who can explain or point me to a link ? I wish to create a blank MS Access DB file programmatically using C# . Thanks, nfs
12
by: Art | last post by:
Hi everyone I was hoping someone might be able to help me with this. I'm just starting to try to work with MS Access tables through VB.net. In Access I can take an existing table and add a new...
2
by: Randy | last post by:
I am trying to relink some Oracle tables in an Access database via VB.NET and ADOX. I receive the following error when executing the cat.ActiveConnection link "Arguments are of the wrong type,...
7
by: OHM | last post by:
OK, before you flame me because this is not an VB/ADO/INTEROP question rather than a VB.NET/ADO.NET/Interop question, I have not had much luck with this so you guys are a last resort. I wonder...
1
by: sunlight_sg | last post by:
Hello, i am using ADOX + VB .NET to create a Access Database programmatically. I plan to set some properties of the column such primary key. The code is as follows: Dim cat As ADOX.Catalog...
6
by: =?Utf-8?B?RyBIdXN0aXM=?= | last post by:
I am creating a new MS Access DB in code, which works fine. I then try to open it & set a password. I keep getting an error that the DB is already open by my machine's Admin account. In reality it...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.