0% found this document useful (0 votes)
13 views46 pages

Expose 104038

The document provides an overview of ADO.NET, a framework for interacting with data sources like databases and XML files, highlighting its benefits, connection architectures, and important classes. It also covers the installation process for Microsoft SQL Server and SQL Server Management Studio, along with steps for connecting to a database using ADO.NET. Key classes such as Connection, Command, DataReader, DataAdapter, and DataSet are explained in detail, emphasizing their roles in data access and manipulation.

Uploaded by

Awal Mamane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views46 pages

Expose 104038

The document provides an overview of ADO.NET, a framework for interacting with data sources like databases and XML files, highlighting its benefits, connection architectures, and important classes. It also covers the installation process for Microsoft SQL Server and SQL Server Management Studio, along with steps for connecting to a database using ADO.NET. Key classes such as Connection, Command, DataReader, DataAdapter, and DataSet are explained in detail, emphasizing their roles in data access and manipulation.

Uploaded by

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

1

CONNECTING AN
ADO.NET TOPIC

APPLICATION TO
A SQL DB
2

TABLE OF CONTENT
-WHAT IS ADO.NET

-BENEFITS OF ADO.NET

-CONNECTION ARCHITECTURES

-IMPORTANT CLASSES IN ADO.NET

-MICROSOFT SQL SERVER

-CREATING, CONNECTING DATABASE IN MYSQL SERVER

-HOW TO CONNECT TO A DATABASE USING ADO.NET


3

WHAT IS ADO.NET?

• ADO.NET is a set of classes (a framework) to


interact with data sources such as databases
and XML files. ADO is the acronym for ActiveX
Data Objects. It allows us to connect to
underlying data or databases. It has classes
and methods to retrieve and manipulate
data.
4

SOME .NET APPLICATIONS


THAT USES ADO.NET

• ASP.NET Web Applications


• Console Applications
• Windows Applications.
5

BENEFITS OF ADO.NET
Interoperability

The ability to communicate across heterogeneous environments.

Scalability

The ability to serve a growing number of clients without degrading


system performance.

Productivity

The ability to quickly develop robust data access applications using


ADO.NET’s rich and extensible component object model.

Performance

An improvement over previous ADO versions due to the disconnected


data model.
6

VARIOUS CONNECTION
ARCHITECTURES

• There are the following two types of connection


architectures:

1.Connected architecture: the application remains


connected with the database throughout the processing.

2.Disconnected architecture: the application


automatically connects/disconnects during the
processing. The application uses temporary data on the
application side called a DataSet.
7

UNDERSTANDING
ADO.NET AND IT'S
CLASS LIBRARY
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).
8

IMPORTANT CLASSES IN
ADO.NET

• We can also observe various classes in the preceding


diagram. They are:

1.Connection Class
2.Command Class
3.Data Reader Class
4.Data Adaptor Class
5.Data Set Class
9

1. CONNECTION
CLASS

• In ADO.NET, we use these


connection classes to connect to the
database. These connection classes
also manage transactions and
connection pooling.
10

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.
• Execute Reader: Returns data to the client as rows. This
would typically be an SQL select statement or a Stored
Procedure that contains one or more select statements. This
method returns a Data Reader object that can be used to fill
a DataTable object or used directly for printing reports and
so forth.
11

• ExecuteNonQuery: Executes a command that


changes the data in the database, such as an
update, delete, or insert statement, or a Stored
Procedure that contains one or more of these
statements. This method returns an integer that is
the number of rows affected by the query.

• ExecuteScalar: This method only


returns a single value. This kind of
query returns a count of rows or a
calculated value.
12

3. DATAREADER CLASS

• DataReader is used to retrieve data. It is used in


conjunction with the Command class to execute
an SQL Select statement and then access the
returned rows.
13

4. DATAADAPTER CLASS

• The DataAdapter is used to connect DataSets to


databases. The DataAdapter is most useful when
using data-bound controls in Windows Forms, but
it can also be used to provide an easy way to
manage the connection between your application
and the underlying database tables, views and
Stored Procedures.
14

5. DATASET CLASS

• The DataSet is the heart of ADO.NET. The DataSet


is essentially a collection of DataTable objects. In
turn each object contains a collection of
DataColumn and DataRow objects. The DataSet
also contains a Relations collection that can be
used to define relations among Data Table
Objects.
THE MICROSOFT 15

SQL SERVER

• Microsoft SQL Server is a relational database


management system developed by Microsoft. As a
database server, it is a software product with the
primary function of storing and retrieving data as
requested by other software applications
WHY THE MICROSOFT
16

SQL SERVER

It provides better performance because it directly


access SQL Server without any middle connectivity
layer.

The .NET Framework Data Provider for SQL server


classes is located in the System.Data.SqlClient
17

HOW TO INSTALL
MICROSOFT SQL SERVER
18

STEP 1

Download installation media from

https://www.microsoft.com/en-us/sql-server/sql-
server-downloads
19

STEP 2

Run the downloaded


file and you will see
the below screen.
Now select the third
option – Download
Media.
20

STEP 3

Now you will see the below


screen. Please select the
language you prefer and
select the ISO radio button to
download the ISO file. In
addition, select the download
location of your choice. I will
go with the default location.
Now press
the Download button.
21

STEP 4
Now it will start
downloading SQL
Server installation
media. It will take
some time based on
your internet
connection speed.
22

STEP 5

After successful
download of
installation media,
you will see the
below screen. Click
the Close button.
23

INSTALL SQL SERVER


2019 DEVELOPER
EDITION

Now that we have installation media,


we can start the installation of the SQL
Server. Let’s see how to install SQL
Server step by step.
24

STEP 1

Run install media file


(ISO file) downloaded in
above section by
double-clicking on it. It
will extract/mount all
the contents in a new
temporary drive.
25

STEP 2
Once extraction is
completed, double click
on the setup.exe file
and you will see the
below screen. Click on
the Installation option in
the left panel and then
click on New SQL
Server stand-alone
installation or add
features to an existing
installation option from
the right panel.
26

STEP 3
Now you will see
the Product
Key window. Select
the Developer option
from the dropdown
and click on
the Next button.
27

STEP 4
Now you will see
the License
Terms window.
Just select the
checkbox and click
on
the Next button.
28

STEP 5

Now you will see


the Microsoft
Update window. It is
not compulsory to
check for the latest
updates but it is
recommended. So,
select the checkbox
and click
the Next button.
29

STEP 6

Now it will check


for updates and
install them if
any.
30

STEP 7

After that, it will check


some rules or
prerequisites for the
installation of SQL
Server. Once all the
rules passed, click on
the Next button.
Sometimes you may
face an error at this
stage.
31

STEP 8
On the Feature Selection window, select features as shown in
the below screenshot. You can also change the location for SQL
Server instance installation but I will go with the default location.
After feature selection please click the Next button.
32

STEP 9
It will check some
feature
rules/prerequisites
and then you will see
the Instance
Configuration screen
. Here you can choose
between Default
Instance and Named
Instance. Here I will
go with Named
Instance.
33

NOTE

Default Instance
When SQL Server is installed in the default instance, it does not require a client to
specify the name of the instance to make a connection. The client only has to know
the server name. For example, HARDIK-PC.

Named Instance

A named instance is identified by the network name of the computer plus the
instance you specify during the installation. The client must specify both the server
name and the instance name when connecting. For
example, HARDIK-PC/MSSQLSERVER.
34

STEP 10

Next, you will see


the Server
Configuration window.
In Service Accounts ta
b,
select Automatic in St
artup Type for SQL
Server Agent, SQL
Server Database
Engine, and SQL
Server
Browser services.
35

STEP 11
Next, you will see
the Database Engine
Configuration window. In
the Server
Configuration tab,
choose Mixed Mode in the
authentication mode section
and enter a strong password.
In Specify SQL Server
administrators section,
your current windows user
should already be added
automatically. If not, click
36

STEP 12
Next, the setup will
check some feature
configuration rules, and
then the Ready to
Install window will
appear. This window
shows the summary of
all the features and
configurations which we
have done in the above
steps. Once review the
summary and click on
the Install button.
37

STEP 13

Now, the
installation will
start and it may
take some time
based on our
configurations.
38

STEP 14
After installation, it
will show you the
list of features and
their installation
status. If any error
occurred, it will
show here.
39

INSTALL SQL SERVER


MANAGEMENT STUDIO
40

STEP 1

Download installation media from

https://learn.microsoft.com/en-us/sql/ssms/download-sql-
server-management-studio-ssms?view=sql-server-ver16
41

STEP 2

Below file will download.


42

STEP 3
Run the downloaded
file and you will see
below screen. Just
click on
the Install button.
43

STEP 4

It will start installing


management studio.
It will take some
time.
44

STEP 5

Once installation
finished, close the
installation wizard
and open start menu
and search for SQL
Server
Management
Studio. You will see
below application.
Now, click on it to
open the application.
45

CONNECTING, CREATING DATABASE


AND TABLES IN MYSQL SERVER
46

HOW TO CONNECT TO A
DATABASE USING ADO.NET

• Now let us learn how to connect to a database


using ADO.NET. To create a connection, you must
be familiar with connection strings. A connection
string is required as a parameter to
SQLConnection. A ConnectionString is a string
variable (not case sensitive).

You might also like