我想在使用組datagridview
總結和展示價值通過總和並顯示在datagridview的數據庫值
string connStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Restaurant.accdb;Persist Security Info=False;";
string query = "SELECT Column2,SUM(Column1),Receipt No,Date From Total Group By[Column2]";
//SELECT Column2 FROM Total GROUP BY [Column2]
using (OleDbConnection conn = new OleDbConnection(connStr))
{
using (OleDbDataAdapter adapter = new OleDbDataAdapter(query, conn))
{
DataSet ds = new DataSet();
if (ds != null)
{
adapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
當這種形式加載它的自動關閉沒有顯示任何datagrdview
嘗試調用Fill之前打開連接,也是您的查詢是錯誤的 – apomene