CLR import of Excel to SQL ...

Last post 08-11-2008, 5:01 AM by Phil Factor. 1 replies.
Sort Posts: Previous Next
  •  05-16-2008, 2:26 PM Post number 53155

    • Bink is not online. Last active: 05-28-2008, 8:08 AM Bink
    • Not Ranked
    • Joined on 05-16-2008
    • Level 1: Deep thought

    CLR import of Excel to SQL ...

    I've gotten a windows application to read an excel file with the following 
    code:
    
            string ExcelConnStr = @"Driver={Microsoft Excel Driver 
    (*.xls)};DBQ=\\Server\Spreadsheets\Test.xls";
            OdbcConnection ExcelConn = new OdbcConnection(ExcelConnStr);
            ExcelConn.Open();
            ExcelConn.Dispose();
    
    However, when I use the same code in a CLR Stored procedure with an external 
    access assembly on a trusted database, I get the following error:
    
    System.Data.Odbc.OdbcException: ERROR [HY001] [Microsoft][ODBC Excel Driver] 
    System resource exceeded.
    ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr 
    failed
    ERROR [HY001] [Microsoft][ODBC Excel Driver] System resource exceeded.
    System.Data.Odbc.OdbcException: 
       at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, 
    RetCode retcode)
       at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, 
    OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
       at 
    System.Data.Odbc.OdbcConnectionFactory.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.Odbc.OdbcConnection.Open()
       at StoredProcedures.usp_ImportExcel()
    .
    
    Any help is appreciated ...
  •  08-11-2008, 5:01 AM Post number 67709 in reply to post number 53155

    Re: CLR import of Excel to SQL ...

    This is an interesting problem. nine times out of ten, the problem actually lies with the SQL Server system user not having the correct permission for the network share. The driver never seems to give the right error information, for some reason. I realise it could be something else, but it is so easy to check that SQL Server has the right permission.
View as RSS news feed in XML