How to Connect .Net Application with Access Database

Step 1: Include the following namespace

using System.Data.OleDb;

Step2: create the connection string

string ConnStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Pawan\Desktop\database.mdb;Jet OLEDB:Database Password=12345";

Step3: making a connection

OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();
OleDbCommand
Cmd = new OleDbCommand(ConnStr, MyConn);

Step4: reading the value from acces database 
        

Cmd.CommandText = "Select * from UserInfo where UserName='"+textBox1.Text+"' and Password='"+textBox2.Text+"'";
OleDbDataReader ObjReader = Cmd.ExecuteReader();
Ebook Download
View all
Learn
View all