I need help with my project please. I am using a service based database in visual studio, When I am adding a row using dataset and sqldataAdapter, the row is added and then I load the content of the database using another method, it shows me the old data of the database and the new row I inserted. However when the application is closed, the database don't update, thank you for your replies:
This the code of inserting a row in the database
string sConnectionString;
sConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\TrainedFacesDB.mdf;Integrated Security=True;User Instance=True";
SqlConnection objConn = new SqlConnection(sConnectionString);
SqlDataAdapter daDistances = new SqlDataAdapter("Select * From TrainedFacesDistances", objConn);
DataSet dsDistances = new DataSet();
daDistances.FillSchema(dsDistances, SchemaType.Source, "TrainedFacesDistances");
daDistances.Fill(dsDistances,"TrainedFacesDistances");
DataRow newDistance = dsDistances.Tables["TrainedFacesDistances"].NewRow();
newDistance["Name"] = "Unknown";
newDistance["EyesDistance"] = ed;
newDistance["EyesCornerDistance"] = ecd;
newDistance["NoseWidth"] = nw;
dsDistances.Tables["TrainedFacesDistances"].Rows.Add(newDistance);
SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(daDistances);
daDistances.UpdateCommand = cmdBuilder.GetUpdateCommand();
daDistances.InsertCommand = cmdBuilder.GetInsertCommand();
daDistances.Update(dsDistances, "TrainedFacesDistances");
objConn.Close();