SQlite local Database data has gone when application restart?
<p>I am developing windows application .Net in C#</p>

<p>DB stored inside the C# Application ".....\SQliteExample\SQliteExample\bin\Debug\MyDatabase.sqlite"</p>

<p>I can insert,update ,view and Delete to the table with the above code and view its contents in another activity with no troubles at all. However, when I restart the application I found that what I have inserted data before I restart the application has gone!</p>

<pre><code>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;
using System.Data.SQLite;

namespace SQliteExample
{
    public partial class Form1 : Form

    {
        SQLiteConnection connection = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;");
        public Form1()
        {
            InitializeComponent();
            SQLiteConnection.CreateFile("MyDatabase.sqlite");
            connection.Open();
            string sql = "create table Employee1 (EmpID int,EmpName varchar(20), age int,Salary int,Phone int , Address Varchar(20))";
            SQLiteCommand command = new SQLiteCommand(sql, connection);
            command.ExecuteNonQuery();

            connection.Close();

        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (connection.State != ConnectionState.Open)
                connection.Open();
            string sql1 = "insert into Employee1 (EmpID,EmpName,Age,Salary,Phone,Address) values (?,?,?,?,?,?)";
            SQLiteCommand command = connection.CreateCommand();
            command.CommandText = sql1;
            command.Parameters.AddWithValue("EmpID", textBox1.Text);
            command.Parameters.AddWithValue("EmpName", textBox2.Text);
            command.Parameters.AddWithValue("Age", textBox3.Text);
            command.Parameters.AddWithValue("Salary", textBox4.Text);
            command.Parameters.AddWithValue("Phone", textBox5.Text);
            command.Parameters.AddWithValue("Address", textBox6.Text);
            command.ExecuteNonQuery();
            connection.Close();
            MessageBox.Show("Data Saved");
            Clear();
            View();
        }
        private void Clear()
        {
            textBox1.Text = string.Empty;
            textBox2.Text = string.Empty;
            textBox3.Text = string.Empty;
            textBox4.Text = string.Empty;
            textBox5.Text = string.Empty;
            textBox6.Text = string.Empty;
        }

        private void View()
        {
            string sql3 = "select * from Employee1 order by EmpID asc";
            SQLiteCommand command3 = new SQLiteCommand(sql3, connection);

            DataTable dt = new DataTable();
            SQLiteDataAdapter da = new SQLiteDataAdapter(command3);
            da.Fill(dt);

            dataGridView1.DataSource = dt;
            connection.Close();

        }

        private void btnSelect_Click(object sender, EventArgs e)
        {
            View();
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBox1.Text))
            {
                if (connection.State != ConnectionState.Open)
                    connection.Open();
                string sql1 = "delete from Employee1 where EmpID = ?";
                SQLiteCommand command = connection.CreateCommand();
                command.CommandText = sql1;

                command.Parameters.AddWithValue("EmpID", int.Parse(textBox1.Text));
                command.ExecuteNonQuery();
                connection.Close();
                Clear();
                View();

            }
            else
            {
                MessageBox.Show("Please Enter EmpID");
            }

        }
    }
    }
</code></pre>

<p>Thanks in Advance,</p>