我想通过c#中的access 2007连接组合框? [英] I want to connect combobox by access 2007 in c#?

查看:58
本文介绍了我想通过c#中的access 2007连接组合框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在尝试将访问2007中的表格连接到c#windows中的组合框...但是它给了我错误...我在c#中基本...我在谷歌上尝试很多但没什么帮助我..请帮助解决

 da.Fill(ds); 

行的错误,该行说出错误Microsoft.ace.oledb.12.0 provider is没有在本地机器上注册......我正在等待你的帮助...非常感谢



 使用系统; 
使用 System.Collections.Generic;
使用 System.ComponentModel;
使用 System.Data;
使用 System.Drawing;
使用 System.Linq;
使用 System.Text;
使用 System.Windows.Forms;
使用 System.Data.OleDb;

命名空间 WindowsFormsApplication32
{
public partial class Form1:Form
{
public Form1()
{
InitializeComponent();

}

private void Form1_Load(< span class =code-keyword> object sender,EventArgs e)
{

OleDbConnection cn = new OleDbConnection( Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\\Users\\\ \\Persian\\Desktop\\a.accdb);
OleDbDataAdapter da = new OleDbDataAdapter( SELECT * FROM Table2,cn);
DataTable ds = new DataTable();
da.Fill(ds);
comboBox1.DataSource = ds;
comboBox1.ValueMember = id;
comboBox1.DisplayMember = val;



}
}
}

解决方案

'Microsoft.ACE.OLEDB.12.0'提供程序未在本地计算机上注册。 [ ^ ]

Hi everyone , i am trying to connect my table in access 2007 to a combobox in c# windows from ... but it giving me error ... i'm basic in c# ... i try alot on google but nothing helped me .. please please help to solve its error on

da.Fill(ds);

line which is saying its error "Microsoft.ace.oledb.12.0 provider is not registered on the local machine" ... i'm waiting for ur kind helps ... many thanks

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 WindowsFormsApplication32
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
           
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            OleDbConnection cn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\\Users\\Persian\\Desktop\\a.accdb");
            OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Table2", cn);
            DataTable ds = new DataTable();
            da.Fill(ds);
            comboBox1.DataSource = ds;
            comboBox1.ValueMember = "id";
            comboBox1.DisplayMember = "val";
            
           
            
        }
    }
}

解决方案

'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.[^]


这篇关于我想通过c#中的access 2007连接组合框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆