WHAT'S NEW?
Loading...

How to fix error Microsoft.ACE.OLEDB.12.0 Provider?

The most common problem encountered when we connect Windows Application into Database is an error occur Microsoft.ACE.OLEDB.12.0 Provider is not registered on the local machine. I been figure out this problem when I copy my project folder into another computer to run my program, definitely the error occur. In addition, I made a program in Visual Basic.Net 2010 in my laptop and my Database is Microsoft Access Database. What happen was, every time I copy the folder of my current project in other computer and paste it to my laptop, after a moment and try to debug the program an errors message display “Microsoft.ACE.OLEDB.12.0 Provider is not registered on the local machine”. I do not know what was happened and I didn’t made wrong when I copy my project, and I assumed that Visual Studio has already added this features. So, I try to search and search to find this problem, asking question on some forum sites, and made some modification on my code if an error occurs in my project when the program was compiled. Fortunately, many thanks for those people who helps to share their expertise to fix this problem. They recommend to install MS Access 2007 or a later version alternatively download and Install the Microsoft Access 2007 Databases Engine from the Microsoft website.

Absolutely, it works smoothly after I installed Microsoft Database Engine. Now, I want to share this to you. Hope this very helpful!

Windows Form Databinding in C# with BindingNavigator


In my previous tutorial which I used Windows Form Databinding in VB.NET to bind data and Customized BindingNavigator component as I used Buttons instead the default BindingNavigator component that enable you to Add, Delete, Update, Retrieve, and Search record.

Actually, it was already done this program before in VB.NET (see How to use BindingNavigator in VB.NET). As a challenge, I migrate VB.NET to C – Sharp (C#) to do this job where in the functions can perform to Add, Delete, Update, Retrieve, and Search record, and most probably all functions and design are almost identical in my previous tutorials. In fact, the code in C# not too far from the code of VB.NET.  However, there are some lines of code that you need to understand it well because of some instances. Let say, to Startup Form. Usually, in VB.NET, we go to Project MenuWindows Application Properties – and set Startup Form which form will be loaded first. In C#, to set the Startup Form you need to double click the Program.cs on your Solution Explorer. This code generated looks like this:

 static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmHome());
        }

To change the Startup Form, you only change frmHome name in which Form you want to load first. Note, the default name of every forms are Form1, Form2, Formn every time you add new Windows Form. It’s better to change the name of every Forms to make it readable and meaningful.

The experience I had while using C# is how to show Form. Before, I can’t find a solution how to work it because in VB is very simple to show Form. This is how:

 Form frm = new frmAdd();
        frm.ShowDialog();

You cannot do (Form1.ShowDialog()) like VB to show form. Instead, initialize first to enable to show other forms.

Those are among few line of codes might take to remember while working in C# if you are VB.NET programmers expertise.

Now, let’s explore the source code:

Code for Add New Entry:

private void btnsave_Click_1(object sender, EventArgs e)
{
  this.Validate();
  this.tblinfoBindingSource.EndEdit();
  this.tblinfoTableAdapter.Update(this.dbInfoDataSet.tblinfo);
  MessageBox.Show("New Records has been successfully saved", "Save Record",    
  MessageBoxButtons.OK, MessageBoxIcon.Information);
  this.tblinfoBindingSource.AddNew();
}

Code for Update Records:

private void btnupdate_Click(object sender, EventArgs e)
{
  this.Validate();
  this.tblinfoBindingSource.EndEdit();
  this.tblinfoTableAdapter.Update(this.dbInfoDataSet.tblinfo);
  MessageBox.Show("Records has been successfully updated", "Update Records",    
  MessageBoxButtons.OK, MessageBoxIcon.Information);
}

The code for Add and Update works in the same way as you have noticed.

Code for Delete Records:

private void btndelete_Click(object sender, EventArgs e)
{
     int x;
     string fname;
     string lname;

     x = this.tblinfoDataGridView.Rows.IndexOf(this.tblinfoDataGridView.CurrentRow);
     fname = this.tblinfoDataGridView.Rows[x].Cells[0].Value.ToString();
     lname = this.tblinfoDataGridView.Rows[x].Cells[1].Value.ToString();
     if (MessageBox.Show("You want to delete" + fname + " " + lname + " records?", "Confirm 
        Entry", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == 
        System.Windows.Forms.DialogResult.Yes)
     {
        this.tblinfoBindingSource.RemoveAt(this.tblinfoBindingSource.Position);
        this.tblinfoTableAdapter.Update(this.dbInfoDataSet.tblinfo);
        MessageBox.Show(fname + " " + lname + " " + "record has been successfully deleted");
     }
     else
     {
        MessageBox.Show("Cancelled","Cancelled 
        Entry",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
     }
}

Code for Retrieve Records:

  this.tblinfoTableAdapter.Fill(this.dbInfoDataSet.tblinfo);

Code for Search Records:

private void txtsearch_TextChanged(object sender, EventArgs e)
{
  this.tblinfoBindingSource.Filter = "Firstname LIKE '%" +txtsearch.Text + "%' OR Lastname 
  LIKE '%" + txtsearch.Text + "%'";
}

The screenshots are almost identical in my previous article. Download this source code hereIf you want to save more files online and share it to your friends, sign up for free.