I am trying to insert data into my database throgh Entity framwork my code is below

private POSDatabaseEntities1 posde = new POSDatabaseEntities1();

    private void btnSave_Click(object sender, EventArgs e)
            Tbl_Users Users = new Tbl_Users();
            Users.FirstName = txtFName.Text;
            Users.LastName = txtLName.Text;
            Users.CNICNumber = txtCNIC.Text;


            MessageBox.Show("Record has successuffly beem Saved");

Although i am geting the messagebos but when i close my application and open table data the entry is not inserted i am stuck with this why it is not giving errors

3 Years
Discussion Span
Last Post by de Source

Are you running this in debug mode using a file based DB system? If so, Visual Studio makes a copy of the database so you don't mess up the original while debugging.


yes indeed..
i am not fimilar with these modes much but i have tried after changing the mode that is from debug to release mode(which was only other option) but still it is not saving data into db
what could be the remedy for this

Edited by de Source: typo


Also you're declaring an object called posde, but you're using an object called RBSDE. Is this on purpose?


i did a mistake while copying here i have used the same object bt unable to.
i cant figure it out that y i am not havng any error if it is not inserted in db

Edited by de Source


Your problem might be in the type of object that Tbl_Users is. If it's a custom class then you might have to but the data into something like a datarow that can be inserted into a datatable. The problem could also be in RBSDE. what kind of object is it?

Edited by tinstaafl


basicaly RBSDB is the database entity in my previous code as it wsnt wroking i made some mistake then again i made the whole project from the scrape with the new database entity name posde
as i said here i used the entity model Tbl_Users is made by the entity model but m stuck now wroking with sql quries

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.