问题
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