[英]C# ASCX Module DataGrid doesn’t show values to 2 decimal places from MySQL-Workbench database table
[英]C# WPF DataGrid doesn't show decimal from SQLite 3 database
我遇到了C#WPF的問題,我想在WPF DataGrid控件中顯示一些SQLite數據表。 我們將產品的價格存儲為NUMERIC(但也嘗試為REAL,但它完全相同),但在datagrid控件中它顯示為整數,盡管在SQLite數據庫瀏覽器中它顯示正確的十進制值。 以下是我們將數據填入DataGrid的代碼:
ProductsDataGrid.ItemsSource = db.GetDataSet("*", "products").Tables[0].AsDataView();
並且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;
}
簡短版本:程序在SQLite DB的數據網格中將十進制數字顯示為int
檢查你的SQLite小數分隔符,也就是它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.