I am using ADOX to make changes to an Access database that would be
difficult to do via the System.Data.OLEDBClient. So far I have no
trouble actually doing the work, however, I have trouble closing the
connection to the Access database.
//open connection
ADOX.CatalogClass connection = new ADOX.CatalogClass();
connection.let_ActiveConnection(this.ConnectionStr ing);
//do the work
....
//close the connection
((ADODB.Connection) connection.ActiveConnection).Close();
Marshal.ReleaseComObject(connection);
Even though the code to close the connection does cause an error, it
doesn't actually close the connection, because if I try to connect to
the database later, it errors out saying that it is exclusively locked.
How do I actually close the connection created via ADOX?
Thanks 4 10709
Frank,
Just off the top of my head, do you have connection pooling turned on?
Perhaps this has something to do with it.
Also, did you dispose of the catalog class properly?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Frank Rizzo" <no**@none.com> wrote in message
news:e5*************@TK2MSFTNGP14.phx.gbl... I am using ADOX to make changes to an Access database that would be difficult to do via the System.Data.OLEDBClient. So far I have no trouble actually doing the work, however, I have trouble closing the connection to the Access database.
//open connection ADOX.CatalogClass connection = new ADOX.CatalogClass(); connection.let_ActiveConnection(this.ConnectionStr ing);
//do the work ...
//close the connection ((ADODB.Connection) connection.ActiveConnection).Close(); Marshal.ReleaseComObject(connection);
Even though the code to close the connection does cause an error, it doesn't actually close the connection, because if I try to connect to the database later, it errors out saying that it is exclusively locked.
How do I actually close the connection created via ADOX?
Thanks
Nicholas Paldino [.NET/C# MVP] wrote: Frank,
Just off the top of my head, do you have connection pooling turned on? Perhaps this has something to do with it.
Also, did you dispose of the catalog class properly?
Well, I guess that's the crux of the matter. How does one dispose of it
properly?
I thought
Marshal.ReleaseComObject(connection);
will do the trick.
Frank,
Yes, you are releasing the connection, but that is not the only COM
object there is. There is also the catalog object.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Frank Rizzo" <no**@none.com> wrote in message
news:u6**************@TK2MSFTNGP09.phx.gbl... Nicholas Paldino [.NET/C# MVP] wrote: Frank,
Just off the top of my head, do you have connection pooling turned on? Perhaps this has something to do with it.
Also, did you dispose of the catalog class properly?
Well, I guess that's the crux of the matter. How does one dispose of it properly?
I thought
Marshal.ReleaseComObject(connection);
will do the trick.
Nicholas Paldino [.NET/C# MVP] wrote: Frank,
Yes, you are releasing the connection, but that is not the only COM object there is. There is also the catalog object.
Connection is the catalog object. Consider the code:
//open connection
ADOX.CatalogClass connection = new ADOX.CatalogClass();
connection.let_ActiveConnection(this.ConnectionStr ing);
//do the work
....
//close the connection
((ADODB.Connection) connection.ActiveConnection).Close();
Marshal.ReleaseComObject(connection); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Developer98115 |
last post by:
I need help getting schema information from an existing SQL Server
database. My thought was that you could use ADOX via InterOp. Has
anyone done this successfully and how? I have created a...
|
by: Gandalf |
last post by:
I'm creating relationships between tables using VBA and ADOX. I can
create one-to-one relationships with an inner join, but I can't figure
out how to create these relationships with an outer join...
|
by: Claudia Fong |
last post by:
Hello,
I'm using the sql statement below to create a new table from an old one.
But I found a little problem with that.
In my old table DEP2004, I have one field's property allow zero length...
|
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,...
|
by: Tim Frawley |
last post by:
I am attempting to change the ODBC Link Provider String in an Access
database linked to an Oracle server using ADOX in VB.NET.
I created some code using the example from post:...
|
by: gaffar |
last post by:
Sir, Using ADOX
I am developing an application in vb.net and the backend database is
ms-access. i have created ms-access databse and tables and assigned primary
keys to the tables through the...
|
by: genojoe |
last post by:
Using ADOX to update a Property does not work.
I want to change the Access database for a linked table. My abridged code is:
Dim oCAT As ADOX.Catalog
oCAT = New ADOX.Catalog...
|
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...
|
by: Hexman |
last post by:
I'm creating a new Access table using ADOX. I can add columns and
indexes, but I'm baffled on how to change field properties. Can
someone give me a hand?
Want to change properties such as:...
|
by: Miro |
last post by:
Something weird I have run into when trying to add a boolean field to an
Access table by code.
-Just wondering if anyone else has run into this. ( vb.net 2005 express )
If I add any other...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |