none
IErrorInfo.GetDescription failed with E_FAIL(0x80004005)

    General discussion

  • Hi everyone, I've read a few posts about this problem and everyone says that sql keywords are the problem and that enclosing the keywords in square brackets solves the problem but this hasn't worked for me. Here's my code.

    An example of the generated sql in the select statement looks like this

    select [Address],
    count(case when [Status] = 'Hard' then 1 end) as HardBounces,
    count(case when [Status] = 'Soft' then 1 end) as SoftBounces
    from BadRecips.csv
    group by [Address]
    order by [Address]

    This query works when run in query analyser against a database table but when I run it using the Microsoft.Jet.OLEDB.4.0 provider against a csv file I get the OleDb Exception "IErrorInfo.GetDescription failed with E_FAIL(0x80004005)". Does anyone have any ideas? Thanks to everyone who looks at this post.

    Here's the code.

    1using System; 
    2using System.Collections; 
    3using System.Collections.Generic; 
    4using System.ComponentModel; 
    5using System.Data; 
    6using System.Data.Sql; 
    7using System.Data.SqlClient; 
    8using System.Drawing; 
    9using System.Text; 
    10using System.Windows.Forms; 
    11using System.Data.OleDb; 
    12using System.IO; 
    13 
    14private DataSet ImportCSV() 
    15        { 
    16            txtFilePath.Text = ofdCSV.FileName; 
    17            FileInfo fi = new FileInfo(ofdCSV.FileName); 
    18            string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Text;Data Source=" + fi.DirectoryName; 
    19            OleDbConnection objConn = new OleDbConnection(sConnectionString); 
    20            DataSet dsDispatchError = new DataSet(); 
    21            try 
    22            { 
    23                objConn.Open(); 
    24 
    25                //Select the data from the CSV 
    26                string strQuery = "select [" + Properties.Settings.Default.EmailColumnName + 
    27                "], count(case when [" + Properties.Settings.Default.ErrorColumnName + "] = '" + Properties.Settings.Default.HardBounceValue + "' then 1 end) as " + 
    28                Properties.Settings.Default.HardBounceColumnName + ", count(case when [" + Properties.Settings.Default.ErrorColumnName + "] = '" + Properties.Settings.Default.SoftBounceValue + "' then 1 end) as " + 
    29                Properties.Settings.Default.SoftBounceColumnName + " from " + fi.Name + " group by [" + Properties.Settings.Default.EmailColumnName + 
    30                "] order by [" + Properties.Settings.Default.EmailColumnName + "]"
    31 
    32                OleDbCommand objCmdSelect = new OleDbCommand(strQuery, objConn);                
    33                 
    34                OleDbDataAdapter objAdapter1 = new OleDbDataAdapter(); 
    35                objAdapter1.SelectCommand = objCmdSelect; 
    36                objAdapter1.Fill(dsDispatchError, "DispatchError"); 
    37            } 
    38            catch (Exception ex) 
    39            { 
    40                txtFilePath.Text = String.Empty; 
    41                MessageBox.Show(ex.ToString()); 
    42            } 
    43            finally 
    44            { 
    45                objConn.Close(); 
    46                ShowOrHideTabs(); 
    47            } 
    48            return dsDispatchError; 
    49        } 

    • Changed type Kira Qian Friday, March 27, 2009 10:08 AM
    Saturday, March 21, 2009 4:57 PM

All replies

  •  

    Hi ernie99,

    "Address" and "Status" are not Reserved Keywords. You don't need to add square brackets, actually it doesn't solve the problem.

    Here is the step you can test.
    1. Add a break point at
    OleDbCommand objCmdSelect = new OleDbCommand(strQuery, objConn);
    Debug your code, when the break point is hurt. take a quick watch at "strQuery", does the text what you expected? Copy the text to the command in query analyser. Does it run properly?

    2. Open connection just before "objAdapter1.Fill(dsDispatchError, "DispatchError");", do not open it earlier than OleDbCommand and OleDbDataAdapter are initialized.

    Does it works for you?

    Sincerely,
    Kira Qian


    Please mark the replies as answers if they help and unmark if they don't.
    Tuesday, March 24, 2009 3:45 AM
  •  

    We are changing the issue type to “General Discussion” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by opening the Options list at the top of the post editor window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.


    Please mark the replies as answers if they help and unmark if they don't.
    Friday, March 27, 2009 10:08 AM
  • Hi Kira, thank you for your reply and my apologies for the late reponse.

    It is something to do with this part of the query

    count(case when [Status] = 'Hard' then 1 end) as HardBounces,
    count(case when [Status] = 'Soft' then 1 end) as SoftBounces

    If I change the query from

    select [Address],
    count(case when [Status] = 'Hard' then 1 end) as HardBounces,
    count(case when [Status] = 'Soft' then 1 end) as SoftBounces
    from BadRecips.csv
    group by [Address]
    order by [Address]

    to

    select [Address]
    from BadRecips.csv
    group by [Address]
    order by [Address]

    then it works.

    "Here is the step you can test.

    1. Add a break point at
    OleDbCommand objCmdSelect = new OleDbCommand(strQuery, objConn);
    Debug your code, when the break point is hurt. take a quick watch at "strQuery", does the text what you expected? Copy the text to the command in query analyser. Does it run properly?

    2. Open connection just before "objAdapter1.Fill(dsDispatchError, "DispatchError");", do not open it earlier than OleDbCommand and OleDbDataAdapter are initialized."

    You can't directly copy the contents of "strQuery" to the Query Analyser window and expect it to run because Query Analyser is not using the Microsoft.Jet.OLEDB.4.0 Provider therefore you get

    Invalid object name 'BadRecips.csv'

    Perhaps this query is just not possible using this provider against a text file.

    FULL EXCEPTION DETAILS

    {System.Data.OleDb.OleDbException: IErrorInfo.GetDescription failed with E_FAIL(0x80004005).
       at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
       at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
       at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
       at AbasoftSubscriptionMonitor.ManageSubscription.ImportCSV() in C:\Users\admin\Documents\Visual Studio 2005\Projects\AbasoftSubscriptionMonitor\AbasoftSubscriptionMonitor\ManageSubscription.cs:line 229}
    Saturday, March 28, 2009 1:11 PM
  • Have u resolved the above issue... If so could u guide me in resolving it.. I been fed up with the same issue for some time....
    Thursday, April 08, 2010 9:53 AM