Link to home
Start Free TrialLog in
Avatar of codefinger
codefingerFlag for United States of America

asked on

How to use datasource with Visual Studio Express 2010 (CONTINUED...)

Looks like I was a bit hasty in accepting the answer to the previous related question.

It says if I add my datasource (in my case VeraDB.sdf)  to my project, then the database file will be copied
to the output directory each time the project is built.

So the question then is, why is that not happening?   Using the |DataDirectory| macro SHOULD have worked,
but the program still complains it cannot find the database file.   If I manually copy the database file into the
target: C:\Documents and Settings\Al Bogus\My Documents\Visual Studio 2010\Projects\VERA\VERA\bin\Debug, then the program can find it when I debug.  But I don't get why I should have to do that.  Is that not supposed to happen automatically if Copy Always is set as a property of the Datasource?

What is it I have failed to do, then?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of puppydogbuddy
puppydogbuddy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of codefinger

ASKER

Nice try, but this does not apply as I used all the default installation paths.
I deleted the VeraDB.sdf database every where I could find in on my hard drive, and deleted it from my project, then restored one copy from the recycle bin, copied it to a folder within my project, then added it to my project again.   When I built this time, the database file was copied into the bin directories and the program was able to find it using the |DataDirectory| macro.  So essentially my problem is solved, but I am curious...

When I modified data (added a new row to a table),  none of the modified file dates changed for any of the copies of the database file, even after a build.   (I was trying to determine which of four possible copies I was actually performing work on when I worked from within the IDE.)  Does the file date of the sdf file change only when one changes the structure of the database, but not when changes are made to the data it contains?
Avatar of puppydogbuddy
puppydogbuddy

I am not 100% positive, but I believe you are correct in stating that the file date of the sdf changes only when their has been a structural change via the designer.  

As for the problem with the of the installed folders after setup , here is a problem that was reported with VS 2008 that indicates that the default install folder is the current folder.  The link also contains code to test for the existance of the sdf file in the current path.  You might want to include such a test for future installations before attempting to open the sdf file.
          http://www.daniweb.com/forums/thread163305.html
Not sure where the problem was, but it is solved, and that is what is important.