c#读access数据库

本文提供了一个使用OLEDB从本地Access数据库读取数据的C#程序示例,包括连接数据库、执行SQL查询和遍历查询结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

using System;
using System.Data;
using System.Data.OleDb;
using System.Collections.Generic;
using System.Text;

class Program
{
static void Main(string[] args)
{
OleDbConnection thisConnection = new OleDbConnection(
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\cinda_dafen_simple.mdb");
thisConnection.Open();
OleDbCommand thisCommand = thisConnection.CreateCommand();
thisCommand.CommandText = "SELECT * FROM 采购项目招标信息表";
OleDbDataReader thisReader = thisCommand.ExecuteReader();
while (thisReader.Read())
{
Console.WriteLine("\t{0}\t{1}", thisReader[0], thisReader[1]);
}

while (thisReader.Read())
{
DataRow row = thisReader.Read();
foreach(row.)
}


thisReader.Close();
thisConnection.Close();
Console.WriteLine("数据库读取完成!");
Console.ReadLine();
}
}

 

转载于:https://www.cnblogs.com/vivicai/p/4446634.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值