0

I'm building my application using .NET.

I created a SQLExpress database instance using Visual Studio and connected to it using LINQ.

This is its connection string

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\TicTacToeDB.mdf;Integrated Security=True;User Instance=True

This database contains only one table named Player.

enter image description here

I coded a stored procedure to insert a player named InsertPlayer

This code is to insert a new player.

TicTacToeDBLINQDataContext context = new TicTacToeDBLINQDataContext();
int? id = 0;
context.InsertPlayer("player1", 0, 0, 0, DateTime.Now, ref id);
context.SubmitChanges();

The problem is nothing is committed in the database and no new record is added.

I figured out that there is an inner copy of the .mdf file in bin/Debug directory. This copy is being used to insert data in.

But when I select data it gives me data from the outer version

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ibrahim.I
  • 229
  • 1
  • 4
  • 18

1 Answers1

0

check the Value of Copy to Output Directory property of your database [right click on mdf file and go to properties], if it is Copy always change it to Copy if newer

Read http://msdn.microsoft.com/en-us/library/ms233817.aspx for more information

Damith
  • 62,401
  • 13
  • 102
  • 153