Step 1

Create a mdb file in MS Access as follows:
  • Open MS Access
  • Choose Blank Database
  • Save it as Microsoft Office Access Database (2000) format
Hence your mdb file is created.
Step 2

Create a table in your database.
Step 3

Create a Windows form with a button for connectivity.
Step 4

Import system.Data.OleDb
  1. using System.Data.OleDb;
Now on button click event connect with MS Access:
  1. using System.Data.OleDb;
  2. namespace WindowsFormsApplication3
  3. {
  4. public partial class Form1 : Form
  5. {
  6. public Form1()
  7. {
  8. InitializeComponent();
  9. }
  10. OleDbConnection conn;
  11. private void btnConnect_Click(object sender, EventArgs e)
  12. {
  13. var DBPath = Application.StartupPath + "\\Connection.mdb";
  14. conn = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + DBPath);
  15. conn.Open();
  16. System.Windows.Forms.MessageBox.Show("Connected successfully");
  17. }
  18. }
  19. }
Hence your connection is established,