'Microsoft.ACE.OLEDB.12.0'提供程序未注册 [英] 'Microsoft.ACE.OLEDB.12.0' provider is not registered

查看:109
本文介绍了'Microsoft.ACE.OLEDB.12.0'提供程序未注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:'Microsoft.ACE.OLEDB.12.0'提供商未在本地计算机上注册。



  protected   void  Button1_Click( object  sender,EventArgs e) 
{


if (FileUpload1.HasFile)
{
string path = string .Concat((Server.MapPath( 〜/ temp / + FileUpload1.FileName)));
FileUpload1.PostedFile.SaveAs(path);


OleDbConnection OleDbcon = new OleDbConnection( Provider = Microsoft.ACE.OLEDB.12.0; server = + path + ;扩展属性= Excel 12.0;);

OleDbCommand cmd = new OleDbCommand( SELECT * FROM [Sheet1 $],OleDbcon);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter(cmd);
OleDbcon.Open();
DbDataReader dr = cmd.ExecuteReader();

string connectionString = @ Data Source = .\sqlexpress; Initial Catalog = testdb; User Id = abc; Password = abc123;;
con);


SqlBulkCopy bulkInsert = new SqlBulkCopy(connectionString);
bulkInsert.DestinationTableName = table_temp;
bulkInsert.WriteToServer(dr);
OleDbcon.Close();
Array.ForEach(Directory.GetFiles((Server.MapPath( 〜/ temp /))),File.Delete);
Label1.ForeColor = Color.Green;
Label1.Text = 已成功插入;

}
else
{
Label1.ForeColor = Color.Red;
Label1.Text = 请选择文件;
}
}
}

解决方案

,OleDbcon);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter(cmd);
OleDbcon.Open();
DbDataReader dr = cmd.ExecuteReader();

string connectionString = @ 数据Source =。\sqlexpress; Initial Catalog = testdb; User Id = abc;密码= abc123;;
con);


SqlBulkCopy bulkInsert = new SqlBulkCopy(connectionString );
bulkInsert.DestinationTableName = table_temp;
bulkInsert.WriteToServer( dr);
OleDbcon.Close();
Array.ForEach(Directory.GetFiles((Server.MapPath( 〜/ temp /))),File.Delete);
Label1.ForeColor = Color.Green;
Label1.Text = 已成功插入;

}
else
{
Label1.ForeColor = Color.Red;
Label1.Text = 请s选举文件;
}
}
}


Google搜索 [ ^ ]?


使用与ADO.NET的Microsoft Access数据库连接时您可能收到此错误

Microsoft.ACE.OLEDB.12.0提供程序未在本地计算机上注册
Microsoft.Jet.oledb.4.0提供程序未注册在本地机器上
等...
解决方案: -
您需要将解决方案平台从任何CPU更改为x86。步骤如下所示
1.右键单击解决方案资源管理器中的解决方案文件
2.单击配置管理器。
3.单击Active Platform下拉,如果x86已经存在,则选择该项,否则单击New
4.从新平台下拉列表中选择x86
5.编译并运行您的应用程序,

如果您仍然遇到问题,请尝试安装Office系统驱动程序





OLEDB提供商未在本地计算机上注册 [ ^


ERROR: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

protected void Button1_Click(object sender, EventArgs e)
        {


            if (FileUpload1.HasFile)
            {
                string path = string.Concat((Server.MapPath("~/temp/" + FileUpload1.FileName)));
                FileUpload1.PostedFile.SaveAs(path);

               
                OleDbConnection OleDbcon = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;server=" + path + ";Extended Properties=Excel 12.0;");

                OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Sheet1$]", OleDbcon);
                OleDbDataAdapter objAdapter1 = new OleDbDataAdapter(cmd);
                OleDbcon.Open();
               DbDataReader dr = cmd.ExecuteReader();

               string connectionString = @"Data Source=.\sqlexpress;Initial Catalog=testdb;User Id=abc; Password=abc123;";
               con);


               SqlBulkCopy bulkInsert = new SqlBulkCopy(connectionString);
                bulkInsert.DestinationTableName = "table_temp";
                bulkInsert.WriteToServer(dr);
                OleDbcon.Close();
                Array.ForEach(Directory.GetFiles((Server.MapPath("~/temp/"))), File.Delete);
                Label1.ForeColor = Color.Green;
                Label1.Text = "successfully inserted";

            }
            else
            {
                Label1.ForeColor = Color.Red;
                Label1.Text = "Please select the File";
            }
}
}

解决方案

", OleDbcon); OleDbDataAdapter objAdapter1 = new OleDbDataAdapter(cmd); OleDbcon.Open(); DbDataReader dr = cmd.ExecuteReader(); string connectionString = @"Data Source=.\sqlexpress;Initial Catalog=testdb;User Id=abc; Password=abc123;"; con); SqlBulkCopy bulkInsert = new SqlBulkCopy(connectionString); bulkInsert.DestinationTableName = "table_temp"; bulkInsert.WriteToServer(dr); OleDbcon.Close(); Array.ForEach(Directory.GetFiles((Server.MapPath("~/temp/"))), File.Delete); Label1.ForeColor = Color.Green; Label1.Text = "successfully inserted"; } else { Label1.ForeColor = Color.Red; Label1.Text = "Please select the File"; } } }


Googling[^]?


While working with Microsoft Access Database connectivity with with ADO.NET you might have received this error
 
The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine
The 'Microsoft.Jet.oledb.4.0' provider is not registered on the local machine
etc ...
Solution:-
You need to change the Solution Platform from "Any CPU" to "x86". The steps are given below
1. Right Click on the Solution File in Solution Explorer
2. Click on the Configuration Manager.
3.Click on the Active Platform Drop down, If x86 is already there then select that, else Click on New 
4.Select x86 from the new platform dropdown 
5.Compile and Run your application, 
 
If you are still facing the issue then try installing Office System Driver 



OLEDB Provider is Not Registered on the Local Machine[^]


这篇关于'Microsoft.ACE.OLEDB.12.0'提供程序未注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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