473,581 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using ADOX with C#.

I am using ADOX to make changes to an Access database that would be
difficult to do via the System.Data.OLE DBClient. So far I have no
trouble actually doing the work, however, I have trouble closing the
connection to the Access database.

//open connection
ADOX.CatalogCla ss connection = new ADOX.CatalogCla ss();
connection.let_ ActiveConnectio n(this.Connecti onString);

//do the work
....

//close the connection
((ADODB.Connect ion) connection.Acti veConnection).C lose();
Marshal.Release ComObject(conne ction);

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
Jan 6 '06 #1
4 10734
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.co m

"Frank Rizzo" <no**@none.co m> wrote in message
news:e5******** *****@TK2MSFTNG P14.phx.gbl...
I am using ADOX to make changes to an Access database that would be
difficult to do via the System.Data.OLE DBClient. So far I have no trouble
actually doing the work, however, I have trouble closing the connection to
the Access database.

//open connection
ADOX.CatalogCla ss connection = new ADOX.CatalogCla ss();
connection.let_ ActiveConnectio n(this.Connecti onString);

//do the work
...

//close the connection
((ADODB.Connect ion) connection.Acti veConnection).C lose();
Marshal.Release ComObject(conne ction);

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

Jan 6 '06 #2
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.Release ComObject(conne ction);

will do the trick.

Jan 6 '06 #3
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.co m

"Frank Rizzo" <no**@none.co m> wrote in message
news:u6******** ******@TK2MSFTN GP09.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.Release ComObject(conne ction);

will do the trick.


Jan 6 '06 #4
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.CatalogCla ss connection = new ADOX.CatalogCla ss();
connection.let_ ActiveConnectio n(this.Connecti onString);

//do the work
....

//close the connection
((ADODB.Connect ion) connection.Acti veConnection).C lose();
Marshal.Release ComObject(conne ction);
Jan 6 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5556
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 Interop reference to the ADOX COM component from my C# project. I am able to open the SqlConnection successfully but it fails with an exception when I...
2
6107
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 (specifically a left outer join). I'm including the code that creates the relationships with the inner join. Any help or suggestions would be...
6
2699
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 is YES, but after creating the new table DEP2005, this property change to NO. It means it won't allow zero lenght.. How can I change this property...
2
7830
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, are out of acceptable range, or are in conflict with one another. Here is my code Dim cat As ADOX.Catalog = New ADOX.Catalo Dim tbl As ADOX.Tabl...
2
8649
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: http://groups.google.com/groups?q=RefreshLinkedTablesWithADOX()&hl=en&lr=&selm=qb1ctvcdoftenojhpp34lb6fjb9ss8qd9c%404ax.com&rnum=1 My code simply replaces the DSN,...
3
1701
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 vb.net application(code is below) by using ADOX. Now my problem is i want delete one record from master table, that deleted record automatically...
2
5513
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 oCAT.ActiveConnection = goConnection Dim t As ADOX.Table Dim p As ADOX.Property
1
3424
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 Dim tbl As ADOX.Table Dim idx As ADOX.Index Dim prp As ADOX.Property
1
11570
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: Description (Column property?), Decimal Places, Caption, Default value, Required indicator, Format, etc.... TIA,
3
3553
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 field other than boolean the "command" version of adding a field works great. But if I try to add a boolean field, I get an exception error when its...
0
7857
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8299
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7890
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8163
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6545
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5355
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3813
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1397
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1127
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.