ADO
ADO
NET
The following are a few of the .NET applications that use ADO.NET to connect to a
database, execute commands and retrieve data from the database.
In this diagram, we can see that there are various types of applications (Web
Application, Console Application, Windows Application and so on) that use ADO.NET to
connect to databases (SQL Server, Oracle, OleDb, ODBC, XML files and so on).
We can also observe various classes in the preceding diagram. They are:
1. Connection Class
2. Command Class
3. DataReader Class
4. DataAdaptor Class
5. DataSet.Class
1. Connection Class
2. Command Class
The Command class provides methods for storing and executing SQL statements and
Stored Procedures. The following are the various commands that are executed by the
Command Class.
4. DataAdapter Class
5. DataSet Class
SQL Authentication
Or:
Windows Authentication
Or:
2. Handle exceptions.
and
(text/storedprocedure).
using System;
using System.Data.SqlClient;
namespace AdoNetConsoleApplication
class Program
new Program().CreateTable();
try {
// Creating Connection
// Opening Connection
con.Open();
// Iterating Data
while (sdr.Read())
// Displaying Record
}
catch (Exception e)
finally
con.Close();