none
Error on excel connection in vs2012 RRS feed

  • Question

  • I have a VS2012 project that has been running fine with no issues but today I just started getting this error:

    System.Data.OleDb.OleDbException (0x80004005): Unspecified error
       at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
       at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.OleDb.OleDbConnection.Open()
       at HL7Import.Form1.CreateMgtSpreadsheet()

    My code is as follows (it is crashing on the excelConnection.Open command):

           Dim ExcelConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" & _
                               "Data Source=" & C:\data.xlsm & ";" & _
                               "Extended Properties=""Excel 12.0 Macro;HDR=YES""")
          
           ExcelConnection.Open()

    Nothing has changed either in the code or on the windows account running it. So I am at a loss as to why it just started firing this error.

    Monday, March 25, 2013 7:27 PM

Answers

  • Whenever I have seen this error it's usually related to database corruption or NTFS permissions, especially in the case of Microsoft Access and the multi-user locking files (.ldb and .accdb). More common with web apps than desktop apps.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Wednesday, March 27, 2013 4:15 PM

All replies

  • If nothing has changed in your code than something changed in the Excel file that is causing the error on the Open method.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Monday, March 25, 2013 8:16 PM
  • I don't think its the spreadsheet. I tried a different spreadsheet and got the same thing. The generic account I am using to run it hasn't changed in months. If I run it under my account it works fine. So there's something that it doesn't like about the generic account but what??? Nothing has changed.  
    Monday, March 25, 2013 9:28 PM
  • Something had to change with the generic account.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Monday, March 25, 2013 10:14 PM
  • That wasn't it either although that's what I thought too.

    The server it runs on was rebooted last night and today it works fine (no changes were made to the account). So it was something on the server although I have no idea what. I also have a process that compacts our access db's during the night that is also written in vs 2012 and last night it crashed as well (before the server was rebooted). It uses Microsoft.Office.Interop.Access.Dao.DBEngine

    Could there have been a program or service that somehow got turned off or stopped that is common to both? It is interesting that both applications seem to have crashed at the point of simply trying to open a file to perform a function.   

    It would be nice to try and figure it out but it may have to remain a mystery unless someone has any ideas.

    Thanks.

    Tuesday, March 26, 2013 3:46 PM
  • Hi,

    I involved the Data expert to further look at this issue. I am moving your thread into the ADO.NET Managed Providers Forum for dedicated support. Thanks for your understanding.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Wednesday, March 27, 2013 8:38 AM
  • That wasn't it either although that's what I thought too.

    The server it runs on was rebooted last night and today it works fine (no changes were made to the account). So it was something on the server although I have no idea what. I also have a process that compacts our access db's during the night that is also written in vs 2012 and last night it crashed as well (before the server was rebooted). It uses Microsoft.Office.Interop.Access.Dao.DBEngine

    Could there have been a program or service that somehow got turned off or stopped that is common to both? It is interesting that both applications seem to have crashed at the point of simply trying to open a file to perform a function.   

    It would be nice to try and figure it out but it may have to remain a mystery unless someone has any ideas.

    Thanks.

    Hello,

    In the future when having an issue that involves a server I would suggest mention this, myself or another person most likely would give different suggestions. Hope you get this resolved soon.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Wednesday, March 27, 2013 11:56 AM
  • You mention "server" so I will assume this is not a Windows Forms (desktop) application. Keep in mind that Excel does not support multi-user access through OLEDB so this could be problematic when accessing from non interactive multi-threaded environments such as a Windows Service or web application.


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Wednesday, March 27, 2013 12:44 PM
  • Yes it is a windows form application using vs 2012.
    Wednesday, March 27, 2013 1:32 PM
  • Whenever I have seen this error it's usually related to database corruption or NTFS permissions, especially in the case of Microsoft Access and the multi-user locking files (.ldb and .accdb). More common with web apps than desktop apps.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Wednesday, March 27, 2013 4:15 PM