简体   繁体   English

C#WPF DataGrid不显示SQLite 3数据库中的小数

[英]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. 我遇到了C#WPF的问题,我想在WPF DataGrid控件中显示一些SQLite数据表。 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. 我们将产品的价格存储为NUMERIC(但也尝试为REAL,但它完全相同),但在datagrid控件中它显示为整数,尽管在SQLite数据库浏览器中它显示正确的十进制值。 Here is the code with which we fill in the data into the DataGrid: 以下是我们将数据填入DataGrid的代码:

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

and the GetDataSet method looks like this: 并且GetDataSet方法如下所示:

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 DB的数据网格中将十进制数字显示为int

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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