473,324 Members | 2,313 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,324 software developers and data experts.

MS access object - db does not get closed

Hello All!

I am using access object to run a module in my access database. The module runs fine. However, the database does not get closed even though I have tried many things to quit\close\release objects. Everytime the calling class tries to open a connection to that db, I get an error saying "cannot use the file".

Following is my code -
-----------------------------------------------------------------------------------------
Access.Application accessObj = null;
accessObj = new Application();
try
{
accessObj.OpenCurrentDatabase(dbPath, true, null);
accessObj.DoCmd.TransferText(AcTextTransferType.ac ImportDelim, importSpecificationName, tableName, filePath, false, null, null);

DAO.TableDefs tdfs = accessObj.CurrentDb().TableDefs;
foreach (DAO.TableDef td in tdfs)
{
if (td.Name.Contains("_ImportErrors"))
{//log error }
}
if (isSuccess)
{
object oMissing = System.Reflection.Missing.Value;
object result = accessObj.Run(functionName, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing);
accessObj.DoCmd.Close(AcObjectType.acModule, moduleName, AcCloseSave.acSaveNo);
}
accessObj.CloseCurrentDatabase();
accessObj.DoCmd.Close(AcObjectType.acDefault, null, AcCloseSave.acSaveNo);
}
catch (Exception exp)
{
}
finally
{
accessObj.Quit(AcQuitOption.acQuitSaveNone);
Marshal.ReleaseComObject(accessObj);
Marshal.FinalReleaseComObject(accessObj);
accessObj = null;
}
-----------------------------------------------------------------------------------------

I have been trying to fix this for long now. Please someone help me see what wrong I am doing here.
Thank you in advance...
Dec 30 '09 #1
0 1311

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

Similar topics

5
by: John Marshall | last post by:
Hi, Does anyone see a problem with doing: data = file("tata").read() Each time this is done, I see a new file descriptor allocated (Linux) but not released. 1) Will there ever be a point...
3
by: Dave | last post by:
Hiya, Anybody know how to do this please? I am opening Access from VB using the code below. However, I don't want Access to close when objAccess goes out of scope. I would like Access to remain...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
6
by: Serious_Practitioner | last post by:
....or lack thereof... I use Access 2000 which I own as part of Office 2000 Professional. I've had enough trouble with glitches to ask if these are common occurrences - 1. Sometimes the "Help"...
0
by: Andrew Dowding | last post by:
Hi Everybody, I have been looking at problems with my Windows Forms C# application and it's little Jet 4 (Access) database for the last few days. The Windows Forms app implements a facade and...
17
by: rdemyan via AccessMonster.com | last post by:
With A2003, I'm having trouble accessing files in a folder on another computer where back-end files, update files, etc are located. Here's the scenario: 1) Computer #1 - A2003 2) Computer #2 -...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
9
by: Anil Gupte | last post by:
I have a MDI Parent Child set of forms FormContainer --MDIParent FormStart --MDIChild FormMain-->MDIChild FormSliceInfo-->MDIChild I use the following in the beginning of FomrContainer ...
1
by: sphinney | last post by:
All, I'm not sure how to adequately explain my problem in two sentences or less, so at the risk of providing TMI, here's the condensed verion. I have developed an Access 2002 database file that...
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...
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)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.