UNIT : -(6)
CONNECTING DATABASE WITH ADO.NET
Content:
•ADO.NET Architecture
•Data provider and its core object
•DataSet class
•Data Binding
•SQL Data Source
3. INTRODUCTION
• ADO.net is an object oriented set of libraries that allows you to interact with data sources. Commonly,
the data sources in database, but it could be a text file, and an excel spreadsheet, or an XML file.
• ADO.NET is a set of classes that expose data access services for .NET Framework programmers.
• ADO.NET provides a rich set of components for creating distributed, data-sharing applications.
• It is an integral part of the .NET Framework, providing access to relational, XML, and application data.
• ADO.NET supports a variety of development needs, including the creation of front-end database
clients and middle-tier business objects used by applications, tools, languages, or Internet browsers.
• ADO.net provides a set of components for creating distributed, data sharing applications. It is an
integral part of.net framework, providing access to relational, XNL, and application data.
Dhruv Vekariya
196080316059
4. • Ado.net is a data access technology from Microsoft.net framework, which provides communication
between relational and non-relational systems through a common set of components.
ADO.NET ARCHITECTURE
Dhruv Vekariya
196080316059
5. Components of ADO.NET
ADO.NET has two main components
• Data provider
➣ Microsoft SQL server
➣ OLE DB
➣ OBDC etc.
• Data Set
➣ It is a tabular representation of data
➣ It represents complete set of data that includes tables, constraint and relationships among the
tables.
Dhruv Vekariya
196080316059
6. Data provider and its core object
ADO.NET core objects
• Core name space: system.data
• .NET framework data providers
Data provider Namespace
SQL Server System.Data.SQLClient
OLE DB System.Data.OleDb
ODBC System.Data.Odbc
Oracle System.Data.Oracle client
Dhruv Vekariya
196080316059
7. ADO.NET core objects
Object Description
Connection
Establishes a connection to a specific data
source
Command
Executes a command against a data source.
Exposes parameters and can execute within
the scope of transaction from a connection.
Data reader
Reads forward-only, read iPhone only stream
of data from a data source.
Data adapter
Populates a data set and resolves updates
within the data source.
Dhruv Vekariya
196080316059
8. DATASET CLASS
• The data set object is central to supporting disconnected, distributed data scenarios with ADO.net.
• It Can Be Used With Multiple And Differing Data Source, With Xml Data, Or To Manage Data Local To
The Application.
• The Dataset Represents A Complete Set Of Data, Including Related Tables, Constraints And
Relationships Among The Tables.
Dhruv Vekariya
196080316059
10. Disconnected Data access
• To ADO.net disconnected data access architecture for more flexible and powerful than ADO’s
connection oriented data access.
• In connection oriented data access architecture the application makes a connection to the data
source and then interact with it through SQL request using the same connection.
Dhruv Vekariya
196080316059
11. Datatable, Datarow And Datacolumn
• Data table represents relational data into tabular form. ADO.net provides a data table class to create
and use data table independently.
• It can also be used with data set also. Initially, when we create data table, it does not have table
schema.we can create table schema by adding columns and constraints to the table.after defining
table schema, we can add rows to the table.
• We must include system.data namespace before creating data table.
Dhruv Vekariya
196080316059
12. • A data view enables you to create different views of the data stored in a Data table, a capability that is
often used in data-binding applications.
• Using a data view, you can expose the data in a table which different sort orders, and you can filter the
data by row state or based on filter expression.
• A data view provides you with a dynamic view of single set of data, much like database view, which
you can apply different sorting and filtering criteria.
Dataview
Dhruv Vekariya
196080316059
13. Data Binding
• Data binding, in the context of dot NET, is the method by which controls on user interface (UI) of a
client application are configured to fetch from, or update data into, data source, such as a database or
XML document.
• Data binding is the process that establishes a connection between the application UI and business
logic.
• If the binding has the correct settings and the data provides the proper notifications, when the data
changes its value, the elements that are bound to the data reflect changes automatically.
• Types of data binding:-
Dhruv Vekariya
196080316059
14. SQL DATA SOURCE
• An SQL database data source represents a relational database or another source of data that can be
accessed using an SQL database DSA.
• The configuration properties for the data source specify connection information for the underlying
source of data.
➣ A DB2® database
➣A MySQL database
➣An application that provides a generic ODBC interface
➣A character-delimited text file
• You create SQL database data sources using GUI.
Dhruv Vekariya
196080316059
15. Selecting, updating and deleting records
• The Select Command property of Sql Data Source can also be set to a stored procedure name instead
of SQL command text.
Command :-“ StoredProcedure ”
• The Sql Data Source control supports Update operations when its Update Command property is set and
Delete operations when its Delete Command.
• The Update Command or Delete Command should contain parameter placeholders every values
passed by Grid view control.
• We can specify an Update parameter or Delete parameter collection to set properties for each
parameter.
Dhruv Vekariya
196080316059
16. • This shows the operation
➣ insert, update, delete
• You can enter some domain data because or a
great view want display great view headers if it
contains null value at that time we cannot see
text boxes to enter new record.
Example
Column Name Data type
User ID
Int(Set identity
property=true)
Username Varchar(50)
First name Varchar(50)
Last name Varchar(50)
City Varchar(50)
Designation Varchar(50)
Dhruv Vekariya
196080316059