OledbException was unhandled Could not find file

I am working on windows form which connects to an Access 2007 database,

When i run my appln and  i got the  error Message

"Oledb Exception was unhanded Could not find file

 'C:\Users\MS\Documents\Visual Studio 2008\Projects\Test\bin\sms.accdb"
prashanth agsoftware engineer Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Did you go to the file path,  'C:\Users\MS\Documents\Visual Studio 2008\Projects\Test\bin\sms.accdb", to see if the database file sms.accdb is in that directory?
Jacques Bourgeois (James Burger)PresidentCommented:
In many projects, this is the path in which the application is compiled and running from during development. This thus becomes the default path for files. If you specify a file name without specifying it's path, the system will automatically look into that one.

It is thus possible that the location string is not completely defined, and the system looks into the default path to find id.

Find your connection string and make sure that it is defined with the whole path for the file.

Or move the database into the bin directory while you are debugging.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
prashanth agsoftware engineer Author Commented:
i found articles from google and have changed the default path to relative path

connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\" & "SMS.mdb"

Open in new window

it still gives the same error
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Jacques Bourgeois (James Burger)PresidentCommented:
There is a problem with Access when it uses the JET database (.mdb files). I heard that it was corrected with the new data engine used for .accdb files, but I was never able to confirm it because I have completely switched to SQL Server and never used .accdb files.

You might try to see if it corrects your problem.

The old database engine did not recognize .mdb files if it was running on a 64-bit computers and the application was not explicitly compiled for 32-bits.

The solution was simply to set the Target CPU to x86 in the Build tab (Compile tab in VB) of the project's Properties window.
prashanth agsoftware engineer Author Commented:
i follow your instructions
Tools --> Options --> Projects and Solutions-->General  Checked  "Show advanced build configurations"
In Build tab i am not see any  "x86".
Two things

1) Your original question mentioned accdb but you are using mdb in your last comment.

2) You are still not using relative path in your connection string. Try chaning

Data Source=" & Application.StartupPath & "\" & "SMS.mdb"


Data Source=SMS.mdb
prashanth agsoftware engineer Author Commented:
thank you all
Jacques Bourgeois (James Burger)PresidentCommented:
You have assigned the points. Does it mean that you have solved your problem?

Tools...Options is used to configure Visual Studio, not the project.

The project's Properties Window can be accessed through the last option under the Project menu. You will find x86 in the Build tab in there.
prashanth agsoftware engineer Author Commented:
i solved it by  your inputs
1. sms.accdb not in that  directory  i convert it .mdb to .accdb
2.moved the database into the bin\debug directory
3.corrected the connection string
prashanth agsoftware engineer Author Commented:
Jacques Bourgeois,

i found x86 project's Properties--> Build -->platform Target :
and unfortunately i  can't edit assigned points  but i can say
special thanks to u
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.