我自己建了一个Access数据库,里面只有一个表。我想用c#建立一个程序查询这个表的所有内容。下面是我的代码,请高人指点下。为什么失败,怎么样才能成功。
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Data;
namespace ConsoleApplication6
{
  class Program
  {
  static void Main(string[] args)
  {
  String connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db1.mdb";
  OleDbConnection connection = new OleDbConnection(connectionString);//建立连接
  OleDbCommand cmd = new OleDbCommand("select * from 表1" , connection);
  connection.Open();
  OleDbDataReader aReader = cmd.ExecuteReader();
  Console.WriteLine("This is the returned data from emp_test table");
  while (aReader.Read())
  {
  Console.WriteLine(aReader.GetInt32(0).ToString());
  }
  aReader.Close();
  connection.Close();
    
  }
  }
}