System.Data.OleDb.OleDbException: System resource exceeded

1.1k views Asked by At

I am getting this issue while trying to read data from an excel file using OleDb.

This is working fine on my test server (Window Server 2008) but not working in UAT server with the same configuration.

It used to work on the UAT server, but suddenly stopped working.

I tried solutions from these sources, but nothing worked:

Intermittent "System resource exceeded" exception for OleDB connection to Microsoft Access data file

OleDbException System Resources Exceeded

System resource exceeded

using (OleDbConnection conn = new OleDbConnection(connectionString))
{
    using (OleDbCommand cmd = new OleDbCommand())
    {
        using (OleDbDataAdapter dataAdapter = new OleDbDataAdapter())
        {
            cmd.Connection = conn;
            //Fetch 1st Sheet Name
            //conn.Open();

            DataTable dtSchema;
            dtSchema = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
            string ExcelSheetName = dtSchema.Rows[0]["TABLE_NAME"].ToString();

            //conn.Close();

            ////Read all data of fetched Sheet to a Data Table
            //conn.Open();
            cmd.CommandText = "SELECT * From [" + ExcelSheetName + "] Where (F3 = 'Reconstructive' OR F3 = 'Neurovascular' OR F3 = 'Orthobiologics') AND F2 = '"+ SterileProduct.CatalogNumber +"'";
            dataAdapter.SelectCommand = cmd;
            dataAdapter.Fill(dt);
        }
    }
}

Any help would be appreciated. Thanks

1

There are 1 answers

0
Girish On BEST ANSWER

Hope this will be helpful for others.

I went through numerous resource regarding this issue and found many solutions -programmatically and configuration based answers, unfortunately, none of the solutions worked for me and finally, i decided to use CSV file instead excel. everything is working fine now.

Let me know if anybody found any answer to this question.

Thanks