2023年11月23日发(作者:)
C#读取本地mdb⽂件
1.添加⼯具类
using System;
using c;
using ;
using ;
using ;
using ;
namespace
{
public class MDBHelp
{
private string _fileName;
private string _connectionString;
private OleDbConnection _odcConnection;
///
/// 构建函数
///
/// 根据sql命令返回⼀个DataSet
///
/// sql命令
///
public DataSet GetDataSet(string sql)
{
Open();//打开连接
DataSet ds = new DataSet();
try
{
OleDbDataAdapter adapter = new OleDbDataAdapter(sql, this._odcConnection);
(ds);
}
catch (Exception ex)
{
throw new Exception("sql语句: " + sql + " 执⾏失败!");
}
Close();//关闭连接
发布评论