代码如下:private void Form1_Load(object sender, EventArgs e)
        {            string cn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "//fridge.mdb" + ";Persist Security Info=True";            OleDbConnection cnn = new OleDbConnection(cn);
            string mysel = "Select fridg_id as 分组编号,"+" fridge_Tem as 温度,"+" fridge_Time as 时间 From fridge";
            OleDbCommand com = new OleDbCommand(mysel, cnn);
            DataTable dt = new DataTable("fridge");
            OleDbDataAdapter da = new OleDbDataAdapter(com);
            da.SelectCommand = com;
            OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
            da.Fill(dt);
            this.dataGridView1.DataSource = dt;  
        }

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.OleDb;namespace WindowsApplication31
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {
                string cn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "//fridge.mdb" + ";Persist Security Info=True";            OleDbConnection cnn = new OleDbConnection(cn);
                string mysel = "Select fridg_id as 分组编号," + " fridge_Tem as 温度," + " fridge_Time as 时间 From fridge";
                OleDbCommand com = new OleDbCommand(mysel, cnn);
                DataTable dt = new DataTable("fridge");
                OleDbDataAdapter da = new OleDbDataAdapter(com);
                da.SelectCommand = com;
                OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
                da.Fill(dt);
                this.dataGridView1.DataSource = dt; 
            }
        }
    }
    我这里没有提示错误信息啊,你在看看吧,把我的这段代码拷贝过去看
      

  2.   

     Select fridg_id as 分组编号  估计是这里错了,我想可能是:Select fridge_id as 分组编号
      

  3.   

    我用的是Accesss数据库,在查询分析器里找不到数据库啊
      

  4.   

     mysel = "Select fridg_id as 分组编号,"+" fridge_Tem as 温度,"+" fridge_Time as 时间 From fridge"; mysel = "Select fridg_id as 分组编号, fridge_Tem as 温度, fridge_Time as 时间 From fridge"; 不知道 有啥区别