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.GetDescription failed with E_FAIL(0x80004005).
is being generated at the code
Expand|Select|Wrap|Line Numbers
- da.Fill(dt);
Expand|Select|Wrap|Line Numbers
- 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();
- }
- }
- }
thanx in advance. :)