i am trying to read html file through OLEDB reader using following code
DataTable dTable;
string strDataSource = "";
string strDBFile = "";
long intPos = 0;
strDataSource = mstrFilePath;
dTable = new DataTable();
mCon = new System.Data.OleDb.OleDbConnection();
mCon.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + openFileDialog1.FileName + ";Extended Properties=\"HTML Import;HDR=NO;IMEX=1\";");
if (mCon.State == ConnectionState.Closed)
{
mCon.Open(); // gettting failed here
}
dTable = mCon.GetSchema("Tables");
bSelectionChanged = true;
lstTables.Items.Clear();
foreach (DataRow DRow in dTable.Rows)
{
if (DRow["TABLE_TYPE"].ToString() == "TABLE" || DRow["TABLE_TYPE"].ToString() == "VIEW")
{
intPos = DRow["TABLE_NAME"].ToString().LastIndexOf("FilterDatabase");
lstTables.Items.Add(DRow["TABLE_NAME"]);
}
}
if (lstTables.Items.Count == 1)
{
lstTables.Visible = false;
grdSampleDataControl.Dock = DockStyle.Fill;
}
else
{
lstTables.Visible = true;
grdSampleDataControl.Dock = DockStyle.None;
}
bSelectionChanged = true;
dTable.Dispose();
mCon.Close();
openFileDialog1.Dispose();
It is getting failed here wiht exception\
The Microsoft Office Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data.
But file is not opened anywhere ??
Edit
On debug, When it throws exception at mCon.Open()
, If i press F10 compiler moves to next statement and run the programm succesfully. why it is so ??