Click here to Skip to main content
12,696,092 members (29,951 online)
Rate this:
 
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 2:24am
conanzz307
Comments
Krunal Rohit 16-Dec-12 7:29am
   
Please first rebuild your solution...
conanzz 16-Dec-12 7:32am
   
I did, got the same error
Krunal Rohit 16-Dec-12 8:13am
   
ok clean it and rebuild...
conanzz 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 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 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 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 :)
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

Remove namespace [dbo]<tablename> (remove dbo) from the queries you are using. I removed it and it worked. The namespace redirects the connection to the shared folder of Microsoft
  Permalink  
Comments
CHill60 11-Oct-14 12:03pm
   
dbo with Access? As you can see from the solution posted 2 years ago it was a connection string problem.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

follow the path given and copy your database file(like abc.accdb) their .it will work
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.170118.1 | Last Updated 29 Nov 2016
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100