Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# VisualStudio2008中的ssis microsoft.ace.oledb.12.0错误_C#_C# 4.0_Ssis_Office Interop_Excel Interop - Fatal编程技术网

C# VisualStudio2008中的ssis microsoft.ace.oledb.12.0错误

C# VisualStudio2008中的ssis microsoft.ace.oledb.12.0错误,c#,c#-4.0,ssis,office-interop,excel-interop,C#,C# 4.0,Ssis,Office Interop,Excel Interop,这是我从excel工作表中读取列并保存到数据表中的代码,该数据表在我的Visual Studio 2010控制台应用程序中运行良好,但当我在使用Visual Studio 2008的SSIS项目中使用此代码时,我在SSIS包中使用了确切的代码,然后我收到一个错误Microsoft.ACE.OLEDB.12.0提供程序不可用在本地计算机上注册 我是SSIS新手,我的其他SSIS VS2008项目工作正常,但在这一个项目中,我必须从excel读取数据,因此我使用现有代码,但出现此错误 //exc

这是我从excel工作表中读取列并保存到数据表中的代码,该数据表在我的Visual Studio 2010控制台应用程序中运行良好,但当我在使用Visual Studio 2008的SSIS项目中使用此代码时,我在SSIS包中使用了确切的代码,然后我收到一个错误
Microsoft.ACE.OLEDB.12.0提供程序不可用在本地计算机上注册

我是SSIS新手,我的其他SSIS VS2008项目工作正常,但在这一个项目中,我必须从excel读取数据,因此我使用现有代码,但出现此错误

  //excel to data table
            public  System.Data.DataTable exceltodatatable()
            {
                System.Data.DataTable myTable = null; ;
                try
                {

                    System.Data.OleDb.OleDbConnection MyConnection;

                    System.Data.DataSet DtSet;
                    System.Data.OleDb.OleDbDataAdapter MyCommand;
                    //  string path = @"D:\projects\excel\spec.xlsx";
                    //string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";
                    MyConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='D:\\projects\\excel_tEST\\ConsoleApplication13\\ConsoleApplication13\\bin\\Debug\\excel\\clublist.xlsx';Extended Properties=Excel 12.0;");
                    MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection);
                    MyCommand.TableMappings.Add("Table", "TestTable");
                    DtSet = new System.Data.DataSet();
                    MyCommand.Fill(DtSet);
                    myTable = DtSet.Tables[0];
                    MyConnection.Close();
                    myTable.Columns.Add("someNewColumn", typeof(string));
                    int i = 0;
                    foreach (DataRow drOutput in myTable.Rows)
                    {
                        //  drOutput["Preferred Version"] = drOutput["Preferred Version"].ToString().Replace("**", "yes");
                        //your remaining codes
                        int count = drOutput[0].ToString().Length;
                        if (count <= 24)
                        {
                            myTable.Rows[i][1] = "3"; ;
                        }
                        else
                        {
                            myTable.Rows[i][1] = "4"; ;
                        }
                        i++;

                    }
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.ToString());
                }

                // myTable.Columns.Remove("Author");
                return myTable;
            }
//excel到数据表
public System.Data.DataTable exceltodatatable()
{
System.Data.DataTable myTable=null;
尝试
{
System.Data.OleDb.OleDbConnection MyConnection;
System.Data.DataSet数据集;
System.Data.OleDb.OleDbDataAdapter MyCommand;
//字符串路径=@“D:\projects\excel\spec.xlsx”;
//string connStr=“Provider=Microsoft.ACE.OLEDB.12.0;数据源=“+path+”;扩展属性=excel12.0;”;
MyConnection=new System.Data.OleDb.OleDbConnection(“Provider=Microsoft.ACE.OleDb.12.0;数据源='D:\\projects\\excel\u tEST\\ConsoleApplication13\\ConsoleApplication13\\bin\\Debug\\excel\\clublist.xlsx';扩展属性=excel 12.0;”;
MyCommand=new System.Data.OleDb.OleDbDataAdapter(“从[Sheet1$]中选择*”,MyConnection);
添加(“Table”、“TestTable”);
DtSet=new System.Data.DataSet();
MyCommand.Fill(DtSet);
myTable=DtSet.Tables[0];
MyConnection.Close();
Add(“someNewColumn”,typeof(string));
int i=0;
foreach(myTable.Rows中的数据行输出)
{
//Drootput[“首选版本”]=Drootput[“首选版本”].ToString().替换(“**”,“是”);
//你剩下的代码
int count=drootput[0].ToString().Length;

if(count这是当OLEDB驱动程序无法找到您指定的提供程序时给出的错误。鉴于它在Visual Studio中工作(我假设在同一台计算机上),您可以查看是否将应用程序构建为64位而不是32位。您安装的提供程序可能是x86,因此必须从x86应用程序调用

尝试将运行时设置为32位(),看看这是否可以修复错误