none
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.

    Question

  • Hi
    I am developing windows application.
    while i am reading text file using oledb . i got the following error
    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.

    Please give the solution to solve the problem

    Code

                DataSet ds = new DataSet();
                string conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"" + "D:" + "\"; Extended Properties='text;HDR=Yes;FMT=Delimited(,)'";

                //string conString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\;Extended Properties=\""text;HDR=Yes;FMT=Delimited\""";
                conn = new OleDbConnection(conString);
                conn.Open();
                OleDbCommand command = new OleDbCommand();
                command.CommandText = "SELECT * FROM abc";
                command.Connection = conn;
                OleDbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    listBox1.Items.Add(reader[0].ToString());
                }
                conn.Close();

    Happy Coding, RDRaja
    Monday, December 28, 2009 9:20 AM

Answers

  • It could be possible that your text file is opened in notepad or some other editor. Close the opened file before inserting using above code.


    Gaurav Khanna
    Monday, December 28, 2009 9:58 AM

All replies

  • It could be possible that your text file is opened in notepad or some other editor. Close the opened file before inserting using above code.


    Gaurav Khanna
    Monday, December 28, 2009 9:58 AM
  • I also recommend looking into the Unlocker application, which shows currently allocated file handles, and provides an avenue to close them.  I have found this tool to be irreplaceable, especially when dealing with: Ole Automation & Ad-Hoc queries within Sql Server.
    Jaeden "Sifo Dyas" al'Raec Ruiner
    "Never Trust a computer. Your brain is smarter than any micro-chip."
    PS - Don't mark answers on other people's questions. There are such things as Vacations and Holidays which may reduce timely activity, and until the person asking the question can test your answer, it is not correct just because you think it is. Marking it correct for them often stops other people from even reading the question and possibly providing the real "correct" answer.
    Monday, December 28, 2009 5:25 PM
  • Hi

    I Developed an application that runs 100% on Windows XP and Vista. But the moment I run it on a WIndows 7 Machine I get the same error Reply.

    It is definately not open by another user as the database is on the same machine.

    Did you maybe get a solution?


    WilJ
    Tuesday, December 21, 2010 12:19 PM