locked
insert to access 2007 database RRS feed

  • Question

  • User447704385 posted

    Please help to debug this error: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

    I created this project on 64 bit VS 2008 SP1,  .Net framework SP1.

    I have office 2007 (32 bit) installed.


    Thanks.


    web.config:

    <add name="DBConnectionString1" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\MyDB\MyDB.accdb; Persist Security Info=False;" />



    c# code:

    protected void InsertData(string[] CaseN, string[] TestI, string[] TestC)
        {
            String myConn = ConfigurationManager.ConnectionStrings["DBConnectionString1"].ToString();

            OleDbConnection con = new OleDbConnection(myConn);
            OleDbCommand cmd = new OleDbCommand();

            cmd.CommandType = System.Data.CommandType.Text;
            cmd.Connection = con;
            con.Open();
            for (int i = 1; i <= 3; i++)
            {
                String stmt = "insert into [PET FISH-log 2010] values ('" + CaseN[i] + "', '" + TestI[i] + "', '" + TestC[i] + "')";
                cmd.CommandText = stmt;
                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (Exception myExep)
                {
                    con.Close();
                    TextBox1.BackColor = Color.Red;
                    TextBox1.Text = stmt;
                    TextBox2.Text = myExep.ToString();
                }

            }
            con.Close();
            con.Dispose();    
        }


    Wednesday, June 2, 2010 3:54 PM

Answers

  • User447704385 posted

    Basically, if you're on a 64-bit machine, IIS 7 is not (by default) serving 32-bit apps, which the database engine operates on. So here is exactly what you do:

    1) ensure that the 2007 database engine is installed, this can be downloaded at: http://www.microsoft.com/downloads/details.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en

    2) open IIS7 manager, and open the Application Pools area. On the right sidebar, you will see an option that says "Set application pool defaults". Click it, and a window will pop up with the options.

    3) the second field down, which says 'Enable 32-bit applications' is probably set to FALSE by default. Simply click where it says 'false' to change it to 'true'.

    4) Restart your app pool (you can do this by hitting RECYCLE instead of STOP then START, which will also work).

    5) done, and your error message will go away.*/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 2, 2010 5:22 PM