OledbException : IErrorInfo.GetDescription failed with E_FAIL(0x80004005).

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • snehil
    New Member
    • Jun 2009
    • 19

    #1

    OledbException : IErrorInfo.GetDescription failed with E_FAIL(0x80004005).

    Hi,
    I m getting this exception using the following code in a windows Form application using Access database
    can anyone please explain me what m doing wrong..
    similar code with sqlclient is running perfectly fine..
    the exception
    IErrorInfo.GetD escription failed with E_FAIL(0x800040 05).
    is being generated at the code

    Code:
    da.Fill(dt);
    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.OleDb;
    
    namespace MSACCESS
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                
                OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\StickiesTest.mdb");
                OleDbCommand cmd = new OleDbCommand("Select cast(max(id)as integer) from notes;", conn);
                OleDbDataAdapter da = new OleDbDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);
                int n = (int)dt.Rows[0][0];
                textBox1.Text = n.ToString();
    
    
            }
        }
    }
    I'm also attaching the screenshot of database if you wish to see it..

    thanx in advance. :)
    Attached Files
  • snehil
    New Member
    • Jun 2009
    • 19

    #2
    resolved..
    it worked when i removed cast as integer from the sql query..

    Comment

    Working...