0% found this document useful (0 votes)
86 views

Connect To Access Database in CSharp

This document provides steps to connect and insert data into an Access database from a C# application. The steps include creating an Access database, generating a UDL file to specify the connection string, opening the UDL file in a text editor to copy the connection string, and adding code to a C# form to insert records into a table using the connection string.

Uploaded by

Guillan Pascual
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views

Connect To Access Database in CSharp

This document provides steps to connect and insert data into an Access database from a C# application. The steps include creating an Access database, generating a UDL file to specify the connection string, opening the UDL file in a text editor to copy the connection string, and adding code to a C# form to insert records into a table using the connection string.

Uploaded by

Guillan Pascual
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Connect to Access Database in C# and ADO.

NET

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();

You might also like