ado ole方式访问access的两种方式

            OleDbConnection Connection = new OleDbConnection();
            OleDbDataAdapter adapter = null;
            //ConnectiongString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
            //   + Path + ";Extended Properties='Excel 8.0;HDR=no;IMEX=0'";
            ConnectiongString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
            + Path + ";Persist Security Info=False";
            Connection.ConnectionString = ConnectiongString;
            Connection.Open();
            //adapter = new OleDbDataAdapter("SELECT * FROM [MAP仓库库存$] ",
            //                            Connection);
            adapter = new OleDbDataAdapter("SELECT * FROM SunData ",
                                      Connection);
            dtTable = new DataTable();
            DataSet DataSet1 = new DataSet();
            adapter.Fill(DataSet1);
            dtTable = DataSet1.Tables[0];

 

posted @ 2017-04-22 18:21  ChineseMoonGod  阅读(446)  评论(0编辑  收藏  举报