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

Error - System.Data.OleDb.OleDbException: Could not use ''; file already in use. - please help

Hi there,
I am trying to access the access database sitting at

OleDbConnection oleConn = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Crystal
Reports\\Samples\\Database\\xtreme.mdb");

and create a crystal report using c#. I have done every thing but for
some reaspon when i try running my webform its throing the below error.
Is there any thing i am missing or need to do some kind of security
settings?

Please help .
thanks in advance
-L

*********************************Error************ **************************************
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Could not use '';
file already in use.

Source Error:
Line 39: Dataset1 dataSet = new Dataset1();
Line 40: /* Connect to, fetch data and disconnect from database */
Line 41: oleAdapter.Fill(dataSet, "Customer");
Line 42: /* Use Report Engine object model to pass populated dataset
Line 43: to report */

*************************************End of the
error***********************************

Jan 12 '06 #1
6 15340
Apparently the Access database is still open and locked for exclusive
use by something.

Are you accessing it from your app a second time (during the same run)
here? If so then make sure you are explictly closing the connection
from the first time.

Jan 12 '06 #2
I think i am doing it right. But still i am not sure though. Here is
the code i am using...

oRpt = new CustomerSales ();
/* Use ADO.NET object model to set up connection information */
OleDbConnection oleConn = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Crystal
Reports\\Samples\\Database\\xtreme.mdb");
OleDbDataAdapter oleAdapter = new OleDbDataAdapter("SELECT * FROM
Customer", oleConn);
Dataset1 dataSet = new Dataset1();
/* Connect to, fetch data and disconnect from database */
oleAdapter.Fill(dataSet, "Customer");

/* Use Report Engine object model to pass populated dataset
to report */
oRpt.SetDataSource (dataSet);
/* bind report object with data to the Web Forms Viewer */
CrystalReportViewer1.ReportSource = oRpt;

Jan 12 '06 #3
put...

oleConn.Close();

....after the oleAdapter.Fill(dataSet, "Customer"); line. I think you
need to explicitly close the connection to the database each time,
unless you modify the command behavior to do it automatically.

Jan 12 '06 #4
HI joey,
I thought i already replied to it. I am sorry about that. Yes it did
work for me and my bad i never closed the connection object.
thanks for the help
-L

Jan 13 '06 #5
PS: make sure your ASP account can create files in the same folder you MDB
file is.
Access driver creates ldb file which has locking information. Without it
your database will be opened in single user mode

George.
"Learner" <pr****@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
HI joey,
I thought i already replied to it. I am sorry about that. Yes it did
work for me and my bad i never closed the connection object.
thanks for the help
-L

Jan 13 '06 #6
I think it is not a real OleDbException. It is a matter of privilege.
You need to give the ASP account privilege to the folder at which the
xtreme.mdb file resides or move the file into the solution folder.

"Learner" wrote:
Hi there,
I am trying to access the access database sitting at

OleDbConnection oleConn = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Crystal
Reports\\Samples\\Database\\xtreme.mdb");

and create a crystal report using c#. I have done every thing but for
some reaspon when i try running my webform its throing the below error.
Is there any thing i am missing or need to do some kind of security
settings?

Please help .
thanks in advance
-L

*********************************Error************ **************************************
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Could not use '';
file already in use.

Source Error:
Line 39: Dataset1 dataSet = new Dataset1();
Line 40: /* Connect to, fetch data and disconnect from database */
Line 41: oleAdapter.Fill(dataSet, "Customer");
Line 42: /* Use Report Engine object model to pass populated dataset
Line 43: to report */

*************************************End of the
error***********************************

Feb 16 '06 #7

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

Similar topics

1
by: Mark | last post by:
Not sure this is the right place for this questions, but here goes: I get an error message when deleting an table from a Access database. The code is as follows and the error message is after...
4
by: Mark | last post by:
Not sure this is the right place for this questions, but here goes: I get an error message when deleting an table from a Access database. The code is as follows and the error message is after...
3
by: GotdotNet | last post by:
I get this error once in a while and I normally could fix it by restarting IIS. However, I would like to find out what causes this. Can anyone help? -----------------------------error...
1
by: Mark | last post by:
Not sure this is the right place for this questions, but here goes: I get an error message when deleting an table from a Access database. The code is as follows and the error message is after...
9
by: Nathan Sokalski | last post by:
I am recieving an error about not being able to use a file because it is already in use. Based on the error, I think it is referring to my DB, but I don't know how to avoid the error or why it is...
7
by: Jim McGivney | last post by:
ASPX page from VS.net-C# on host's computer using oleDataAdaptor to connect to Microsoft Access database. The page loads, but when connection to the database is attempted to fill a datagrid the...
5
by: petro | last post by:
Hello all, My asp.net web application works on my machine but I get the following error on our test web server, There is only one oracle home on the test server. Does anyone know how to resolve...
6
by: Ben | last post by:
I am trying to migrate my vb6.0 over to vb.net. Here is the error that that I am stuck with: Public myDB As DAO.Database ..... path = System.IO.Path.GetFullPath("..") myDB =...
9
by: dennist685 | last post by:
I created a web project named 'Access' in C:\Inetpub\wwwroot\Access and dropped an .mdb there. I dragged a DetailView to the form, configured it to show two fields of a table, and got...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
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...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.