locked
Connect to an excell file RRS feed

  • Question

  • User1598769658 posted

    Hi,

    We have an MVC application where we have put an excell loader. It works fine in the VS studio environment but on the IIS (64 bit) we get an error message .->

    Microsoft.ACE.OLEDB.12.0 provider is not registrated on the local machine.

    The excell (2010) is 32 bit, but the IIS is 64 bit.

    Here the code
    if (FileUpload.ContentLength > 0)
                {
                   
    
                    string fileName =
    Path.GetFileName(FileUpload.FileName);
                    string path =
    Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/uploads"),
    fileName);
    
                   
                    //try
                    //{
                       
                        FileUpload.SaveAs(path);
                       
    
                        string ConnectionString =
    "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Excel 14.0
    Xml;HDR=YES";
                       
    
                        using (OleDbConnection conn = new
    System.Data.OleDb.OleDbConnection(ConnectionString))
                        {
                            conn.Open();
                            using (DataTable dtExcelSchema =
    conn.GetSchema("Tables"))
                            {
                                ImportTable importTable =
    new ImportTable() { name = FileUpload.FileName, portfolio_id = portfolio.id };
                               
    invest.AddImportTable(importTable);
                                invest.Save();
    
    
                                string sheetName =
    dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
                                string query = "SELECT *
    FROM [" + sheetName + "]";
                                OleDbDataAdapter adapter
    = new OleDbDataAdapter(query, conn);
                                DataSet ds = new
    DataSet();
                                adapter.Fill(ds,
    "Items");
    ...
    
    Friday, March 18, 2011 1:22 PM

All replies

  • User269602965 posted

    set you application CPU target in Advanced Compile options of the MY Project sertting explicitly to x86 and recompile.

    Saturday, March 19, 2011 3:58 PM
  • User1598769658 posted

    Hello,

     

    When we do this, this does not compile correctly. We get a lot of errors.

     

    Kind regards,

     

    Philip

    Wednesday, March 23, 2011 6:40 AM