问题如题,
代码如下
string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=eworld.mdb;Jet OLEDB:Database Password=''";
 SqlConnection conn = new SqlConnection(constr);//进行连接时就会报错 不支持关键字: “provider”。连接串是 用.net自带的数据组建生成的。到网络上搜,有人说是需要安装 MDAC.inf。 按照提示安装了之后还是报这个错误。不知道有没有高手能帮忙解决。

解决方案 »

  1.   

    http://www.cftea.com/c/2007/07/V5CXEBU0V5VDJ3D5.asp
      

  2.   

    楼上给的网址提示去掉 Provider,
    但是去掉之后报错不支持关键字: “jet oledb:database password”。
    还是不行
      

  3.   

    试试
    region Access 2007   
                Console.WriteLine("Access 2007");   
                string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;";   
                strConnection += @"Data Source=C:\Documents and Settings\v-changl\My Documents\Database1.accdb;";   
                strConnection += "Persist Security Info=False";   
                using (OleDbConnection objConnection = new OleDbConnection(strConnection))   
                {   
                    objConnection.Open();   
                    OleDbDataAdapter myCommandd = new OleDbDataAdapter("select * from Couse", objConnection);   
                    DataSet ds = new DataSet();   
                    myCommandd.Fill(ds, "couse");   
                    DataTable dt = ds.Tables["couse"];   
                    Console.WriteLine(dt.Columns[0].ToString());   
                    Console.WriteLine(dt.Columns[1].ToString());   
                    Console.WriteLine(dt.Columns[2].ToString());   
      
                    objConnection.Close();   
      
                }  
                #endregion   
    本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/LCL_data/archive/2009/05/06/4154255.aspx
      

  4.   

    http://www.connectionstrings.com/access
    http://www.connectionstrings.com/access-2007
      

  5.   

    string dbURL="Provider=Microsoft.Jet.Oledb.4.0;Data Source="+Application.Startup+“/data.mdb"尝试一下。
      

  6.   

    用OleDbConnection可以,用SqlConnection连接时会抛出System.ArgumentException: 说不支持关键字: “provider”。
    data source=;User ID=sa;pwd=sa;Initial Catalog=

    使用   OleDbConnection   以及相关类 
    public   static   DataTable   GetDataTable(string   strSQL)   
    {   
    SqlConnection   Conn   =   new   SqlConnection(strConn);   
    try 

    Conn.Open(); 
    SqlDataAdapter   sda   =   new   SqlDataAdapter(strSQL,Conn); 
    DataTable   dt   =   new   DataTable( "dt "); 
    sda.Fill(dt); 
    return   dt; 

    catch(System.Data.SqlClient.SqlException   e) 

    throw   new   Exception(e.Message); 

    finally 

    Conn.Close(); 


      

  7.   

    你题目上说连接的是Access数据库,怎么用SqlConnection啊?
      

  8.   

    恩,是我迷糊了,应该用OleDbConnection。