首页 > 数据库技术 > 详细

【C#学习笔记】读access2007

时间:2017-08-27 16:03:34      阅读:244      评论:0      收藏:0      [点我收藏+]
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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!