-->

Thursday, August 20, 2015

How to connect Microsoft Access Database to Windows Form c#

How to connect Microsoft Access Database to Windows Form c#

Introduction
In this article we will learn how to connect access database to windows form application. Get the MS Access data in windows form application. Access is a database system or you can its a tool of MS-Office. Through this we can store data permanently in it. If you want to store data in it by the help of windows application then you should connect it with the application.

Description
If you want to connect the database with the windows form application then you must to install the MS- Access in the computer. Also must to install connection drivers properly. Now, follow the instruction to connect ms-access database to windows form c#.

  1. First to prepare a database file in MS-Access.
  2. Add a windows form project Using Visual Studio 2013 or earlier.
  3. Add a Method just after Initializing Component. Like 


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Configuration;

namespace ConnectAccessDatabase
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            loadgrid();
        }

        private void loadgrid()
        {
            OleDbConnection con = new OleDbConnection();
            con.ConnectionString = ConfigurationManager.ConnectionStrings["Connection"].ToString();
            con.Open();
            MessageBox.Show("Connection Sucess");
  

        }
    }
}

Read other related articles

Also read other articles

© Copyright 2013 Computer Programming | All Right Reserved