C# WPF DataGrid doesn't show decimal from SQLite 3 database

和自甴很熟 提交于 2020-01-02 06:07:34

问题


I ran into an issue with C# WPF, where I want to show some SQLite data table in WPF DataGrid control. We store the price of a product as a NUMERIC (but also tried as REAL, but it does the very same), but in the datagrid control it is shown as integer, despite on the SQLite DB Browser it shows the proper decimal value. Here is the code with which we fill in the data into the DataGrid:

ProductsDataGrid.ItemsSource = db.GetDataSet("*", "products").Tables[0].AsDataView();

and the GetDataSet method looks like this:

public DataSet GetDataSet(string columns, string table, string trailingCommands = "")
{
    var sqlcmd = string.Format("select {0} from {1} {2}", columns, table, trailingCommands);
    Utility.Log.Info(sqlcmd);
    DataSet dataSet = new DataSet();
    SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(sqlcmd, this.dbconn);
    dataAdapter.Fill(dataSet);

    return dataSet;
}

Short version: The program shows decimal numbers as int in a datagrid from SQLite DB


回答1:


Check your SQLite decimal separator character, that's could be it.



来源:https://stackoverflow.com/questions/39979343/c-sharp-wpf-datagrid-doesnt-show-decimal-from-sqlite-3-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!