mercredi 6 mai 2015

Local database does not submit changes after insert into in Visual Studio/C#

I have this problem with Visual Studio. I have a Service Based Database - KCSDatabase.mdf and 1 table in it- Users. I use it to create a LINQ class of it by drag and drop the table in the context of my UserDataClasses.cs. I have one Stored Procedure - AddNewUser in the database and in UserDataClasses.cs too. For connection it uses the connectionString defined at App.config - My connectionString is :

onnectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\KCSDb.mdf;Integrated Security=True"

So, when I submit a form with user data from registration and debug the app the database does not update the changes after insert into. When I try to add two rows at one session with unique ids - it get me the notification that I can not insert because of the primary key (id) and does not make the changes in database. But if I do it at two separate times - two times I start the app and insert user with same id and it doesnt notify me and it does not make the changes at database too. Somebody says me that it writes somewhere the inserting information (in some file, which is destroyed after closing the app) but does not insert in in the database. This is the code of saveButtonClick event of my form:

UserDataClassesDataContext dc = new UserDataClassesDataContext();

dc.AddNewUser(Convert.ToInt32(tbId.Text),
              tbFirstName.Text,
              tbMiddleName.Text, 
              tbLastName.Text, 
              tbMail.Text, 
              tbUserName.Text, 
              tbPassword.Text);
dc.SubmitChanges();

Aucun commentaire:

Enregistrer un commentaire