Actually my database is storing data temporarily. when I start the application and store the data through application, I can see the data. But after terminating the application the entered data are disappeared. Manually entered data are there. I googled it. I tried every possibilities. But, cant solve it. everyone is saying that when my app runs it create a temporary database, where the data are stored. but after stopping the app ,The original database has not been updated. I am a beginner. I have stuck here for last 3 days. Any one please pull me out. I have to submit my database project. Any help should be appreciated. And please try to say elaborately as I have already mentioned that I am a beginner.
My form1.cs is-->
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace db3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { System.Data.SqlClient.SqlConnection sqlConnection1 = new System.Data.SqlClient.SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Resources\db2.mdf;Integrated Security=True;Connect Timeout=30"); System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = "INSERT [Table] (Id, name) VALUES (5, 'e')"; cmd.Connection = sqlConnection1; sqlConnection1.Open(); cmd.ExecuteNonQuery(); sqlConnection1.Close(); MessageBox.Show("inserted"); } catch(Exception ex) { MessageBox.Show(ex.Message); } } } }the app.config is
<?xml version="1.0" encoding="utf-8" ?><configuration><configSections></configSections><connectionStrings><add name="db3.Properties.Settings.empconstring" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Resources\db2.mdf;Integrated Security=True;Connect Timeout=30" providerName="System.Data.SqlClient" /></connectionStrings><startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /></startup></configuration>