Sqlite database and datagrid
13,751
I used the following in one of my projects :
private void UpdateDataGrid(SQLiteConnection con, string sql)
{
DataSet dataSet = new DataSet();
SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(sql, con);
dataAdapter.Fill(dataSet);
dataGrid.DataSource = dataSet.Tables[0].DefaultView;
}
Columns are generated automatically based on the query, if you want to preview all your table use the following : "SELECT * From TableName"
This worked perfectly in my winforms app, you might need to change a few things for it in WPF tho, I'm not sure.
Author by
pauliustack
Updated on July 20, 2022Comments
-
pauliustack almost 2 years
I am trying to display my database(simple grades database) to wpf datagrid.Maybe someone know good example or simple code of connecting sqlite with datagrid?Also what is better:1.Manually create columns or use autogeneratecolumns? Thanks
-
Barkermn01 almost 9 yearsWhy the hell is this marked as an aswer the question quite clearly says WPF and WinForms is not WPF
you might need to change a few things for it in WPF tho
means nothing this does not work in WPF -
gattsbr about 7 yearsIn looking for an answer to this for WPF i came across the following: codereview.stackexchange.com/a/101266