oledb連接access數(shù)據(jù)庫(kù)示例
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
OleDbConnection conn = new OleDbConnection();
OleDbCommand comm = new OleDbCommand();
OleDbDataReader dr=null;
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Environment.CurrentDirectory + "\\SimpleNews.mdb";
comm.Connection = conn;
comm.CommandText = "select * from [login]";
try
{
conn.Open();
dr = comm.ExecuteReader();
while (dr.Read())
{
for (int i = 0; i < dr.FieldCount; i++)
Console.Write(dr.GetValue(i) + " ");
Console.WriteLine("");
//dr.Close();
}
dr.Close();
}
catch (Exception err)
{
Console.WriteLine(err.Message);
}
finally
{
comm = null;
conn.Close();
comm = null;
Console.ReadKey();
}
}
}
}
相關(guān)文章
C#實(shí)現(xiàn)進(jìn)程管理的啟動(dòng)和停止實(shí)例
這篇文章主要介紹了C#實(shí)現(xiàn)進(jìn)程管理的啟動(dòng)和停止方法,以操作記事本程序?yàn)槔?實(shí)例分析了C#針對(duì)進(jìn)程操作的基本技巧,需要的朋友可以參考下2015-07-07winform 使用Anchor屬性進(jìn)行界面布局的方法詳解
這篇文章主要介紹了winform 使用Anchor屬性進(jìn)行界面布局的方法,有需要的朋友可以參考一下2013-12-12C#快速實(shí)現(xiàn)IList非泛型類(lèi)接口的自定義類(lèi)作為數(shù)據(jù)源
本文主要介紹了C#快速實(shí)現(xiàn)IList非泛型類(lèi)接口的自定義類(lèi)作為數(shù)據(jù)源,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-02-02基于C#實(shí)現(xiàn)員工IC卡的讀寫(xiě)功能
這篇文章主要為大家詳細(xì)介紹了C#如何實(shí)現(xiàn)讀寫(xiě)員工IC卡的功能,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下2023-01-01