The "using" statement in C# is used to import a namespace.
The following coding is coded:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading, Tasks;
using System.Windows. Forms;
using System.Data.OLEDB;
To close a running connection efficiently. The following coding is used:
using System;
using System. Collections.Generic;
using System. ComponentModel;
using System. Data;
using System. Drawing;
using System. Linq;
using System. Text;
using System. Threading, Tasks;
using System. Windows. Forms;
using System. Data. OLEDB;
namespace WindowsFormsApp1
{
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
String constr = “Provider=Microsoft.ACE.OLEDB.12.0;} +
“Data Source=***” +
“Jet OLEDB: Database Password=***”;
using (OLEDBConnection con = new OLEDBConnection (constr))
{
con.Open();
MessageBox.Show(“Connection is Opened!);
}
}
}
}