简体   繁体   中英

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

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

检查你的SQLite小数分隔符,也就是它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM