Database not Found

B

Bernardo Heynemann

The following block of code gives me an error.

MultiBD is my class for multiple databases.

connection= MultiBd.GetConnection(DataProviderType.OLEDB);
connection.ConnectionString = MultiBd.GetConnectionString
(1);
comand = connection.CreateCommand();
comand.CommandText = strSelectComand;
comand.CommandTimeout = 30;
adapter = MultiBd.GetDataAdapter(DataProviderType.OLEDB);
adapter.SelectCommand = comand;

connection.Open();
int numberOfRows = adapter.Fill(myDataSet);
connection.Close();

the connection string is as follows:
Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\inetpub\\wwwroot\\tasks\\db\\db.mdb;User
Id=admin;Password=;

The database is there... But VS.NET gives me this error:
Could not find file 'C:\WINDOWS\SYSTEM32\db.mdb'.
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 find file 'C:\WINDOWS\SYSTEM32\db.mdb'.

Source Error:


Line 219:
Line 220: connection.Open();
Line 221: int numberOfRows = adapter.Fill(myDataSet);
Line 222: connection.Close();
Line 223: // }


Source File:
c:\inetpub\wwwroot\tasks\classes\db\dbinteraction.cs
Line: 221

Any help?

Thanx in advance
Bernardo Heynemann
 
K

Kevin Spencer

Apparently there is not "the" connection string. You stated that your
"MultiBd" class is a class for multiple databases, but you didn't post any
of its code, only stated that "the" copnnection string was what you stated
it was. However, the error indicates that the database location is different
from the location you specified in "the" connection string. Therefore, I
would have to guess that, as you stated that the "MultiBd" class is a class
for more than one database, that it defines more than one connection string,
and that it is returning the wrong one.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
B

Bernardo Heynemann

But I ran the application line by line and the connection string is that.
For sure.
The db opens fine, but when it tries to execute anything it gives me that
error.

Thanx,
Bernardo Heynemann
 
K

Kevin Spencer

But I ran the application line by line and the connection string is that.
For sure.
The db opens fine, but when it tries to execute anything it gives me that
error.

The db does NOT open fine. The error message indicates that the line
throwing the error is the line which attempts to open the Connection TO the
db. Furthermore, the error message indicates that the location it is looking
for the database in is not the location you specified as being in the
Connection String. Since the location of the database is DETERMINED by the
Connection String, it must not be using the Connection String you think it
is.

Without seeing the code for the class that is causing the problem, I can't
tell you anything more.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
B

BruceJohnson

I have to agree that there is a problem with the connection string. It
feels to me like c:\winnt\system32\db.mdb is the default database
(db.mdb) in the location where ADO executable is running. That's what
my gut says.

As to the cause, I wonder about the connection string. In particular
about the multiple slashes between each element in the path. I know, I
know, that how slashes are specified in C#. But I don't know where you
are finding the value of the connection string and I can't help
wondering if maybe the double slashes are not being interpreted the way
that you think they are.

Just my 2 cents.

Bruce Johnson
http://www.ObjectSharp.com/Bruce
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top