Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET database path
I`ve connected an web page with access database, when I try to add a new record, I get this error:
(Could not find file 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\DataBase.accdb'.)
 
note: my data base is already in App_Data folder.
 
and when I copy db file into that path, any inserting will be in that path not in the one in App_Data!!
 
how to fix it to keep changes only in the original database ?
Posted 16-Dec-12 1:24am
conanzz299
Comments
Krunal Rohit at 16-Dec-12 7:29am
   
Please first rebuild your solution...
conanzz at 16-Dec-12 7:32am
   
I did, got the same error
Krunal Rohit at 16-Dec-12 8:13am
   
ok clean it and rebuild...
conanzz at 16-Dec-12 8:17am
   
no use, can u tell me, should I keep a copy in that path: devserver\10.0\.. ?
or just stick with that data base in App_data ?
conanzz at 16-Dec-12 8:23am
   
here is my code: http://img856.imageshack.us/img856/9102/1216201242021pm.jpg
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The message is quite clear, you are trying to use a path to a file that does not exist. Your error is most likely because you are using a relative path for your database in your connection string (.\DataBase.accdb). Change your path to the correct location of your database and try again.
  Permalink  
Comments
conanzz at 16-Dec-12 8:53am
   
well, you`re right, It`ll work when I keep the full path which is
C:\Users\Administrator\Documents\Visual Studio 2010\Projects\WebApplication5\WebApplication5\App_Data\DataBase.accdb
 
put I want to keep it portable for my teacher, I`ll send it to him.
dunno what to call this situation :(
Richard MacCutchan at 16-Dec-12 10:02am
   
If you want to make it portable then you need to add some extra code to locate the file at the start of the application; see this link for more information.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Thanks, been solved by this path String:
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\DataBase.accdb"
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Source=|DataDirectory|\MyDB.mdb"
 
Solved it Smile | :)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid