This article explains to us , how to connect with MS Access 2007 database from C# Windows application.
First of all I would like to say thanks to all
the readers. In this article, I am going to show you how to connect with MS
Access 2007 database from C#.NET windows application. Design our window as follows.
private void btnGetData_Click(object sender, EventArgs e)
string conStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C\TestTable.accdb; Persist Security Info=False;";
OleDbConnection con = new OleDbConnection(conStr);
OleDbCommand cmd = new OleDbCommand("Select Sname,Sal from Tarak where ID="+txtSNO.Text, con);
OleDbDataReader dr = cmd.ExecuteReader();
txtName.Text = dr["SName"].ToString();
txtSal.Text ="$"+ dr["sal"].ToString();
catch (Exception ex)
lblMessage.Visible = true;
lblMessage.Text = ex.Message;
I hope this article helps for connecting with MS Access Database.
Thanks & Regards,
Found interesting? Add this to:
About the Author