从工具栏里面拖一个OleDbConnection进去,然后新建连接,提供程序选择Microsoft Jet4.0 OLE Provider。然后在连接中选择你的mdb文件即可。

解决方案 »

  1.   

    using System.Data.OleDb;string strConnection = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\db1.mdb";
    OleDbConnection cn = new OleDbConnection(strConnection);try
    {
    cn.Open();
    MessageBox.Show("连接成功!");
    }
    catch( OleDbException ex )
    {
    MessageBox.Show( ex.Message );
    }
    finally
    {
    cn.Close();
    }
      

  2.   

    和以前access版本没有什么区别
      

  3.   

    找不到可安装的ISAM啊!怎么办?
      

  4.   

    不会阿。我就是windows2003+office2003
    visual studio.net 2003
      

  5.   

    http://xiyuan.blogdriver.com/66feifei/254688.html
      

  6.   

    如果是Winform程序tonybaobao(Tony宝宝) 即是正解
    Copy到一个Button的OnClick事件里执行一下就可得到结果
    Source=c:\db1.mdb";//注意修改成你真是存在的文件如果是Web的需要给ASP.NET用户权限
    如果是XP或windows2003,工具->文件夹选项->取消简单文件共享
    MDB文件->右键->添加everyone完全权限
      

  7.   

    你把你的代码贴出来呀!还有你的是web还是winform?
      

  8.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Data.OleDb;namespace WindowsApplication4
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Button button1;
    private System.Data.OleDb.OleDbConnection oleDbConnection1;
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.button1 = new System.Windows.Forms.Button();
    this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
    this.SuspendLayout();
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(80, 112);
    this.button1.Name = "button1";
    this.button1.TabIndex = 0;
    this.button1.Text = "button1";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    // 
    // oleDbConnection1
    // 
    this.oleDbConnection1.InfoMessage += new System.Data.OleDb.OleDbInfoMessageEventHandler(this.oleDbConnection1_InfoMessage);
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(292, 273);
    this.Controls.Add(this.button1);
    this.Name = "Form1";
    this.Text = "Form1";
    this.Load += new System.EventHandler(this.Form1_Load);
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void Form1_Load(object sender, System.EventArgs e)
    {
    } private void button1_Click(object sender, System.EventArgs e)
    {
    string strConnection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\My Documents\db1.mdb;";
    OleDbConnection cn = new OleDbConnection(strConnection); try
    {
    cn.Open();
    MessageBox.Show("连接成功!");
    }
    catch( OleDbException ex )
    {
    MessageBox.Show( ex.Message );
    }
    finally
    {
    cn.Close();
    }
    } private void oleDbConnection1_InfoMessage(object sender, System.Data.OleDb.OleDbInfoMessageEventArgs e)
    {

    }
    }
    }
      

  9.   

    重新装个mdac看看
    http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c&displaylang=zh-cn
      

  10.   

    只是連接成功﹐如果能夠把數據源顯示到datagrid里﹐那才行啊﹗﹗﹗
      

  11.   

    private void button9_Click(object sender, System.EventArgs e)
    {
    string source=@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=e:\North.mdb";
    string strsql="select * from supply"; OleDbDataAdapter da=new OleDbDataAdapter(strsql,source); 
    DataSet ds=new DataSet();
    da.Fill(ds,"tab");
    dataGrid1.SetDataBinding(ds,"tab");}
      

  12.   

    hdhai9451(※★開拓者...准備去長安☆※) 出现错误了!
    缺少USING引用,命名空间是什么啊?
      

  13.   

    程序可以运行了!不过如果我的ACCESS设置了密码应该怎么改程序呢?
      

  14.   

    最頂的代碼using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;  -------->加這行       
    using System.Data.OleDb;  -------->加這行
    然后在控件里加上面的代碼
      

  15.   

    加了,还是出错
    缺少USING引用
      

  16.   

    谢谢tonybaobao(Tony宝宝) ,问题解决!万分感谢!!