Click to See Complete Forum and Search --> : Debug issue with using SQL Server DB Files


bigjoe11a
June 3rd, 2009, 01:18 PM
I Use SQL Server 2008 with VC# express in the console. I added a database file to my application and this is what happens.

When I run the program in debug and add a new record to the database file I just created. It seems to insert ok, Just when I exit the program and view the contents of the database file. The records isn't there.

What happens is that I'm using to database files. One in the programs root folder and one in the Debug folder.

The question is how can I point the program to use only one SQL server database *.mdf file when I'm running the program in Debug.

hspc
June 6th, 2009, 04:12 AM
You should change the connection string in your app.config to point to the tight file.
Look at something like:
AttachDbFilename=|DataDirectory|\Database1.mdf

For production work, you should not use the AttachDbFilename. It's better to connect to a SQL server instance that hosts the database if possible.