jeudi 31 mars 2016

How can I create solution setup (.exe) with SQLite file

I try create setup from my test application with sqlite file. Code here:

 public void connection()
    {
        m_dbConnection = new SQLiteConnection(@"Data Source=C:\Program Files (x86)\mato\skuskaSetup\myDB.dat;Version=3;");
        m_dbConnection.Open();
    }

    public void select(string select)
    {
        string sql3 = select;
        SQLiteCommand command3 = new SQLiteCommand(sql3, m_dbConnection);
        command3.ExecuteNonQuery();
        SQLiteDataAdapter adapter = new SQLiteDataAdapter(command3);
        DataTable dt = new DataTable("table1");
        adapter.Fill(dt);
        dataGrid.ItemsSource = dt.DefaultView;
        adapter.Update(dt);
        m_dbConnection.Close();
    }

    private void button_Click(object sender, RoutedEventArgs e)
    {
        connection();
        select(selectFromTbl1);
    }
}

File myDB.dat is included in setup.

If I start app in VS all is OK, but after installation app can not find myDB.dat

Aucun commentaire:

Enregistrer un commentaire