• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 569
  • Last Modified:

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 ag
prashanth ag
3 Solutions
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.
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
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now