The Microsoft Access database engine cannot open or write to the file ''

Posted by snvmohankmr-21264 under ASP.NET on 3/15/2013 | Points: 10 | Views : 3231 | Status : [Member] | Replies : 0
I am installed Microsoft Access Database Engine 2010. after that i dont do anything...because i dont know anything about oledb connection...... Then i am execute the below file then i am getting the following error... The Microsoft 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... ..... How can i solve that... Anyone help me please...If any steps are involved in oledb connection then show that steps please ..........

Aspx file :

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<br />
<span style="color: Red">*</span>Attach Excel file
<asp:FileUpload ID="fileuploadExcel" runat="server" />
<asp:Button ID="btnSend" runat="server" Text="Export" onclick="btnSend_Click" />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" CellPadding="4"
ForeColor="#333333" GridLines="None" PageSize="30">

Aspx.cs File :

public partial class UploadExcel_to_DB : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

protected void btnSend_Click(object sender, EventArgs e)
String strConnection = "Data Source=(local);Initial Catalog=MyDB;Integrated Security=True";
//file upload path
string path = fileuploadExcel.PostedFile.FileName;
//Create connection string to Excel work book
string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;Persist Security Info=False";
//Create Connection to Excel work book
OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
//Create OleDbCommand to fetch data from Excel
OleDbCommand cmd = new OleDbCommand("Select [Business_ Name],[Category] from [Sheet1$]", excelConnection);
OleDbDataReader dReader;
dReader = cmd.ExecuteReader();
SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);
//Give your Destination table name
sqlBulk.DestinationTableName = "exportcheckTB";

Web.config file :

<add name="ApplicationServices"
connectionString="data source=Data Source=(local);Initial Catalog=MyDB;Integrated Security=True"
providerName="System.Data.SqlClient" />

<compilation debug="true" targetFramework="4.0" />

<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />

<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>


<modules runAllManagedModulesForAllRequests="true"/>



(No response found.)

Login to post response