惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threat Research - Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Vulnerabilities – Threatpost
GbyAI
GbyAI
P
Proofpoint News Feed
L
LINUX DO - 热门话题
P
Palo Alto Networks Blog
A
About on SuperTechFans
T
Tenable Blog
M
MIT News - Artificial intelligence
IT之家
IT之家
I
Intezer
D
DataBreaches.Net
爱范儿
爱范儿
T
Threatpost
C
CERT Recently Published Vulnerability Notes
云风的 BLOG
云风的 BLOG
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
K
Kaspersky official blog
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Y
Y Combinator Blog
Cyberwarzone
Cyberwarzone
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Darknet – Hacking Tools, Hacker News & Cyber Security
H
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
Spread Privacy
Spread Privacy
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
AWS News Blog
AWS News Blog
博客园 - 聂微东
C
Check Point Blog
S
Securelist
有赞技术团队
有赞技术团队
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
D
Docker
G
GRAHAM CLULEY
T
The Exploit Database - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tailwind CSS Blog
L
Lohrmann on Cybersecurity
G
Google Developers Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog

博客园 - Richard

使用Expresso学习.net正则表达式 Learning .NET Regular Expressions with Expresso SWOT分析法 Symbian60第二版拍照功能实现 WindowsMobile2003拨号回拨 Windows2003Web权限问题 佣兵天下-看书 以前用过的的一个线程池代码 Symbian60平台开发环境搭建 回归 虚函数,看看吧 sizeof讨厌的东西 C# 下的struct Black Berry 无尽空虚 J2ME下访问.net的webservice 读取ini配置文件的API C#今天学的知识 设置控件输入的输入方式-补充
急用抄过来不整理了-Access
Richard · 2005-06-15 · via 博客园 - Richard

连接Access数据库:
using System;
using System.Data;
using System.Data.OleDb;

class TestADO
{
    static void Main(string[] args)
    {
        string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\test.mdb";
        string strSQL = "SELECT * FROM employees" ;

        OleDbConnection conn = new OleDbConnection(strDSN);
        OleDbCommand cmd = new OleDbCommand( strSQL, conn );
        OleDbDataReader reader = null;
        try
        {
            conn.Open();
            reader = cmd.ExecuteReader();
            while (reader.Read() )
            {
                Console.WriteLine("First Name:{0}, Last Name:{1}", reader["FirstName"], reader["LastName"]);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
        finally
        {
            conn.Close();
        }
    }
}
using System;
using System.Data;  
using System.Data.OleDb;  

class TestADO

    static void Main(string[] args) 
    { 
        string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=c:\test.mdb"; 
        string strSQL = "INSERT INTO Employee(FirstName, LastName) VALUES('FirstName', 'LastName')" ; 
                  
        // create Objects of ADOConnection and ADOCommand  
        OleDbConnection conn = new OleDbConnection(strDSN); 
        OleDbCommand cmd = new OleDbCommand( strSQL, conn ); 
        try 
        { 
            conn.Open(); 
            cmd.ExecuteNonQuery(); 
        } 
        catch (Exception e) 
        { 
            Console.WriteLine("Oooops. I did it again:\n{0}", e.Message); 
        } 
        finally 
        { 
            conn.Close(); 
        }         
    }

十二、使用OLEConn连接数据库:
using System;
using System.Data;  
using System.Data.OleDb;  

class TestADO

    static void Main(string[] args) 
    { 
        string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=c:\test.mdb"; 
        string strSQL = "SELECT * FROM employee" ; 

        OleDbConnection conn = new OleDbConnection(strDSN);
        OleDbDataAdapter cmd = new OleDbDataAdapter( strSQL, conn );

        conn.Open();
        DataSet ds = new DataSet();
        cmd.Fill( ds, "employee" );
        DataTable dt = ds.Tables[0];

        foreach( DataRow dr in dt.Rows )
        {
            Console.WriteLine("First name: "+ dr["FirstName"].ToString() + " Last name: "+ dr["LastName"].ToString());
        }
        conn.Close(); 
    }

十三、读取表的属性:
using System;
using System.Data;  
using System.Data.OleDb;  

class TestADO

    static void Main(string[] args) 
    { 
        string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=c:\test.mdb"; 
        string strSQL = "SELECT * FROM employee" ; 

        OleDbConnection conn = new OleDbConnection(strDSN);
        OleDbDataAdapter cmd = new OleDbDataAdapter( strSQL, conn );

        conn.Open();
        DataSet ds = new DataSet();
        cmd.Fill( ds, "employee" );
        DataTable dt = ds.Tables[0];

        Console.WriteLine("Field Name DataType Unique AutoIncrement AllowNull");
        Console.WriteLine("==================================================================");
        foreach( DataColumn dc in dt.Columns )
        {
            Console.WriteLine(dc.ColumnName+" , "+dc.DataType +" ,"+dc.Unique +" ,"+dc.AutoIncrement+" ,"+dc.AllowDBNull );
        }
        conn.Close(); 
    }
}