SIGN UP MEMBER LOGIN:    
ARTICLE

Connect to Access Database in C# and ADO.NET

Posted by Muhammad Imran Taj Articles | Visual C# February 26, 2008
This artilce explains how to connect and get data from an Access database in C# and ADO.NET.
Reader Level:

These are very simple steps to create and connect an Access database in C#. 

  • Create Access database (e.g  student)



  • Now open you notepad and click on save As button. Name then Imran.hdl. Change save type "ALL FILES".

  • Now double click on imran.udl file. A wizard will start like this:

  • Click Provider TAB, select Microsoft Jet 4.0 OLE DB (denoted by black arrow) then click next. Now click "Select or enter a database name" and select the desire database then click open.

  • Now click on test connection and click OK
  • Now edit this UDL file with note pad and copy link as shown below



  • Now Open Visual Studio editor and create Text boxes and buttons like

  • Double click on the form and add some code

cmd.CommandText = "insert into student values(" + this.textBox1.Text + ",'" + this.textBox2.Text + ",'" + this.textBox3.Text + ",'" + this.textBox4.Text + "');";
int temp = cmd.ExecuteNonQuery();
if (temp > 0)
{
    MessageBox.Show("Record Added");
}
else
{
    MessageBox.Show("Record not Added");
}
mycon.Close();

Login to add your contents and source code to this article
Article Extensions
Contents added by Edgar Picuasi on Jun 15, 2011
gracias
Contents added by dsfdsf dsfdsf on Nov 14, 2009

hx

Contents added by trushant pachnekar on Jul 10, 2009
dfgdfgfdgfd
Contents added by Kirk Vilaimal on May 25, 2009
Hi, I'm Kirk  just  beginner
share this article :
post comment
 

Thanks for your article but something are made me heartly to understand it. On the step "Open Notepad and save as" it mean we already have the notepad yet right ! and how i create it, what code in it ? why we need it ?

Posted by Vichit Dara Feb 12, 2012

Microsoft Jet 4.0 OLE DB is not seen infile.udl saved in OD Windows 7

Posted by Molutty Jun 06, 2011

Microsoft Jet 4.0 OLE DB is not seen infile.udl saved in OD Windows 7

Posted by Molutty Jun 06, 2011

Microsoft Jet 4.0 OLE DB is not seen infile.udl saved in OD Windows 7

Posted by Molutty Jun 06, 2011

i wanted to connect a web form log in with ms access, help needed pls. thank u

Posted by ben z Jun 01, 2011
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Gauge for SharePoint
Become a Sponsor