oledb连接access数据库示例
时间:2024-01-28 05:54:19
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();
}
}
}
}
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
一键搞定python连接mysql驱动有关问题(windows版本)
卷积神经网络经典模型及其改进点学习汇总
![](https://img.aspxhome.com/file/2023/0/86590_0s.png)
Keras搭建分类网络平台VGG16 MobileNet ResNet50
![](https://img.aspxhome.com/file/2023/6/83776_0s.png)
Jupyter notebook无法导入第三方模块的解决方式
![](https://img.aspxhome.com/file/2023/1/72791_0s.jpg)
Python pandas RFM模型应用实例详解
![](https://img.aspxhome.com/file/2023/7/76977_0s.png)
JavaScript对象的property属性详解
JavaScript前端实用的工具函数封装
![](https://img.aspxhome.com/file/2023/5/135465_0s.png)
在go中使用omitempty的代码实例
python3实现往mysql中插入datetime类型的数据
Python使用base64模块进行二进制数据编码详解
python的简单web框架flask快速实现详解
![](https://img.aspxhome.com/file/2023/2/77712_0s.png)
使用Python第三方库发送电子邮件的示例代码
![](https://img.aspxhome.com/file/2023/6/97486_0s.jpg)
Python实现打乒乓小游戏
![](https://img.aspxhome.com/file/2023/1/105391_0s.gif)
Python实战之手写一个搜索引擎
![](https://img.aspxhome.com/file/2023/3/67323_0s.jpg)
TensorFlow 显存使用机制详解
MySQL 5.7.18 免安装版配置教程
![](https://img.aspxhome.com/file/2023/5/85805_0s.png)
python3爬虫获取html内容及各属性值的方法
Mysql临时表及分区表区别详解
![](https://img.aspxhome.com/file/2023/3/111393_0s.png)
PyQt5 显示超清高分辨率图片的方法
![](https://img.aspxhome.com/file/2023/8/114498_0s.png)
vue-cli使用stimulsoft.reports.js的详细教程
![](https://img.aspxhome.com/file/2023/4/139724_0s.jpg)