码迷,mamicode.com
首页 > 数据库 > 详细

【C#学习笔记】读access2007

时间:2017-08-27 16:14:41      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:.exe   ndt   and   ext   text   exec   tab   rom   sel   

using System;
using System.Data.OleDb;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string strConnection = "Provider = Microsoft.ACE.OLEDB.12.0;";
            strConnection += @"Data Source = c:/Database1.accdb ";
            OleDbConnection con = new OleDbConnection(strConnection);
            con.Open();

            OleDbCommand com = con.CreateCommand();
            com.CommandText = "SELECT * FROM 表1";

            OleDbDataReader reader = com.ExecuteReader();

            while (reader.Read())
            {             
                Console.WriteLine((string)reader["姓名"]+"  "+(int)reader["年龄"]+"  "+(string)reader["性别"]);
            }
            reader.Close();
            con.Close();

            Console.Read();
        }      
    }
}

 

【C#学习笔记】读access2007

标签:.exe   ndt   and   ext   text   exec   tab   rom   sel   

原文地址:http://www.cnblogs.com/tiandsp/p/7440431.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!