本文介绍了如何使用C#连接Ms Access数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我连接ms访问数据库时,它会发出错误,例如



未在ConnectionString中指定 OLE DB提供程序。一个例子是'Provider = SQLOLEDB





我的代码是:

while am connecting ms access database it will give an error like

An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB


My code is:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace osman
{
    public partial class Payment : Form
    {
        OleDbConnection con = new OleDbConnection(@"Povider=Microsoft.Jet.OLEDB.4.0;Datasource=D:\\employee.mdb;Persist Security Info=False");
        public Payment()
        {
            InitializeComponent();
        }

        private void btnsub_Click(object sender, EventArgs e)
        {
            con.Open();
            MessageBox.Show("connection success");
            con.Close();
        }
    }
}





请帮帮我..?



please help me..?

推荐答案

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;
Persist Security Info=False;





用于连接ms访问数据库的代码



the code for connecting the ms access database


这篇关于如何使用C#连接Ms Access数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 09:50