i got error like ..........The Microsoft Office Access database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.
Please correct my code
protected void btnSubmit_Click(object sender, EventArgs e)
{
string path = fileupload.PostedFile.FileName;
string strmail = string.Empty;
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";
OleDbConnection objConn = new OleDbConnection(connectionString);
objConn.Open();
String strConString = "SELECT UserName,EmailId FROM [Sheet1$]";
//where date = CDate('" + DateTime.Today.ToShortDateString() + "')";
OleDbCommand objCmdSelect = new OleDbCommand(strConString, objConn);
// Create new OleDbDataAdapter that is used to build a DataSet
// based on the preceding SQL SELECT statement.
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
// Pass the Select command to the adapter.
objAdapter1.SelectCommand = objCmdSelect;
// Create new DataSet to hold information from the worksheet.
DataSet objDataset1 = new DataSet();
// Fill the DataSet with the information from the worksheet.
objAdapter1.Fill(objDataset1, "srr");
DataGrid1.DataSource = objDataset1;
DataGrid1.DataBind();
// Clean up objects.
objConn.Close();
}
}
Loading
Pankaj RawatPosted Apr 5, 2013, 1:08 AM
Check this Out.
http://www.aspdotnet-suresh.com/2013/01/c-microsoft-office-access-database.html
JAYRAMPosted Apr 4, 2013, 12:22 PM
error.........
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.
Pankaj RawatPosted Apr 4, 2013, 5:08 AM
Try This.
In Button Click