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

Adding Record On A Database: Using Using

To add a record to a database, first import the necessary libraries for OleDB connections and data tables. Then in the form load event, declare a connection string to the database and create objects for the connection, data adapter, and data table. The connection string is used to open a connection to the database where the record will be inserted using the data adapter and table.

Uploaded by

Reynel Isla Albo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Adding Record On A Database: Using Using

To add a record to a database, first import the necessary libraries for OleDB connections and data tables. Then in the form load event, declare a connection string to the database and create objects for the connection, data adapter, and data table. The connection string is used to open a connection to the database where the record will be inserted using the data adapter and table.

Uploaded by

Reynel Isla Albo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Adding Record on a Database

First, we need to put the libraries where OleDBConnection, OleDBDataAdapter and DataTable is located.

using System.Data;
using System.Data.OleDb;

then, we will create an object for OleDBConnection, OleDBDataAdapter and DataTable


OleDbConnection con = new OleDbConnection();
OleDbDataAdapter dba = new OleDbDataAdapter();
DataTable dtable = new DataTable();

In the form load, we will declare the connection string for our database
private void Form3_Load(object sender, EventArgs e)
{
string cons="Provider=Microsoft.Jet.Oledb.4.0;Data Source= SPDB.mdb";
con.ConnectionString = cons;

You might also like