actually when you use |DataDirectory| in database connection string,
it automatically maps the path from where your application is started...
so when you debug or run your program by pressing F5 in Visual Studio, it runs from debug folder path so it will automatically map the database which is copied in debug folder...
That database is copied each and every time you compile the code, if you have default setting for that......
so if you want to map the database which is in your current directory or solution then you have to give static path uptill you developing it.... At last before publishing it, you must replace static path with |DataDirectory|.......
For more detail visit
http://www.connectionstrings.com/
Thanks & Regards,
Punit