I am doing this to read :
private bool writetoven(string xlspath)
{
OleDbConnection excelConnection = new OleDbConnection(excelConnectionString)
try
{
OleDbCommand ocmd = new OleDbCommand("select * from [Sheet1$]", excelConnection);
excelConnection.Open();
OleDbDataReader odr = ocmd.ExecuteReader();
string vcode = "";
string pswd = "";
string vname = "";
while (odr.Read())
{
vcode = valid(odr, 0);
pswd = valid(odr, 1);
vname = valid(odr, 2);
insertdataintosql(vcode,pswd,vname);
}
excelConnection.Close();
return true;
}
catch (DataException)
{
return false;
}
finally
{
lblmsg4.Text = "Data Inserted Sucessfully";
}
}
and my connection string is like this:
excelConnectionString = "provider=Microsoft.jet.oledb.4.0;data source=" +
filepath1 +
";extended properties='Excel 8.0;HDR=YES;'";
but I am getting an error as
The Microsoft Jet database engine cannot open the file ''. It is already opened exclusively by another user, or you need permission to view its data.
Line 1574: OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
Line 1575:
Line 1576: excelConnection.Open();
Line 1577:
Line 1578:
It seems like the file is still open but its not and I have checked the running process and its not there
Now what should I do? ...My Excel sheet is closed but I am getting this error
i dont have microsoft access on my com is that can be an issue
is this problem is something to do with my fileupload control that i am using??
excelConnection.Open();twice? Furthermore I would check TaskManager if there is any instance of Excel running in background (not visible) with your file open!