Click here to Skip to main content
15,911,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have one web application and launched on localhost not any server
but i am tried upload any excel on my application then error occured..

The Microsoft Jet database engine cannot open the file 'D:\bombay'. It is already opened exclusively by another user, or you need permission to view its data.

-----------------------------------
i have use this code on upload button click event
protected void Button_upload_Click(object sender, EventArgs e)
    {
        string str = Server.MapPath("files1/" + FileUpload1.FileName);
        //string str = Server.MapPath("files/" + FileUpload1.FileName);
        FileUpload1.SaveAs(str);
        StringBuilder Connection123 = new StringBuilder();
        Connection123.Append(@"Provider=Microsoft.Jet.OLEDB.4.0;Mode=ReadWrite|Share Deny None;Data Source=");
        Connection123.Append(str);
        Connection123.Append(";Extended Properties='Excel 8.0;HDR=YES;'");
        //string constr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath(FileUpload1.FileName) + ";" + "Extended Properties=Excel 8.0;";

        //Create Connection to Excel Workbook
        OleDbConnection connection = new OleDbConnection(Connection123.ToString());
        OleDbCommand command = new OleDbCommand("Select * FROM  [IP_Phone$]", connection);
        connection.Open();

        // Create DbDataReader to Data Worksheet

        OleDbDataReader dr = command.ExecuteReader();
        // SQL Server Connection String
        string sqlConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
        
        SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString);
        bulkCopy.DestinationTableName = "dbo.finish";
        bulkCopy.WriteToServer(dr);
        connection.Close();
    }
Posted
Updated 17-Jun-10 1:44am
v4
Comments
Henry Minute 15-Jun-10 8:06am    
Have you checked if it is, in fact, in use? Does it need a password?
TheyCallMeMrJames 15-Jun-10 9:07am    
Can you set a breakpoint in your code and step through it? I think there's something else going on there. I don't think you should be seeing a Microsoft Jet Database Engine error when you're trying to upload a document. Are you trying to open it before it exists?

1 solution

now i have get solution
...file upload control drag in outside of update panel of ajax..new i am upload excel file with my application...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900