Download presentation
Published byBrendan McCarthy Modified over 8 years ago
2
ADO .NET from
3
“ADO .Net” Evolution/History of ADO.NET
MICROSOFT .NET “ADO .Net” Evolution/History of ADO.NET History: Most applications need data access from some data Source, make data accessing a crucial component for applications. Data access is making the application to interact with a database, where all the data is stored. Different applications have different requirements for accessing different database.
4
“ADO .Net” Evolution/History of ADO.NET
MICROSOFT .NET “ADO .Net” Evolution/History of ADO.NET History: The first data access model, DAO (Data Access object) was created for local databases which had performance and functionality issues. Next came RDO (Remote Data Object) and ADO (ActiveX Data Object) which were designed for Client Server architectures but soon ADO took over RDO. ADO was a good architecture but was a connected data access model, which means that when a connection to the database is established, the connection remains open until the application is closed.
5
MICROSOFT .NET “ADO .Net” History: Leaving the connection open for the lifetime of the application raises concerns about database security and network traffic. Also, as databases are becoming increasingly important and as they are serving more people, a connected data access model makes us think about its productivity. For example, an application with connected data access may do well when connected to two clients, the same may do poorly when connected to 10 and might be unusable when connected to 100 or more. Also, open database connections use system resources to a maximum extent making the system performance less effective.
6
MICROSOFT .NET “ADO .Net” History: To cope up with the problem mentioned last, Dot.Net introduce ADO .NET. ADO .NET addresses the above mentioned problems by maintaining a disconnected database access model which means, when an application interacts with the database, the connection is opened to serve the request of the application and is closed as soon as the request is completed. Likewise, if a database is Updated, the connection is opened only long enough to complete the Update operation and is closed as soon as the operation is completed.
7
MICROSOFT .NET “ADO .Net” History: By keeping connections open for only a minimum period of time, ADO .NET conserves system resources and provides maximum security for databases and also has less impact on system performance. Also, ADO .NET when interacting with the database uses XML and converts all the data into XML format for database related operations making them more efficient.
8
“ADO .Net” Definitions:
MICROSOFT .NET “ADO .Net” Definitions: ADO.NET is an object-oriented set of library classes in .Net that allows you to interact with data sources. Commonly, the data source is a database (Microsoft SQL Server, Microsoft Access, Oracle etc), but it could also be a text file, an Excel spreadsheet, or an XML file.
9
MICROSOFT .NET “ADO .Net” ADO.NET is generally considered as a part of the base class library that is included with the Microsoft .NET Framework. It is commonly used by programmers to access and modify data stored in relational database systems, though it can also access data in non-relational sources. Note: ADO.NET is sometimes considered an evolution of ActiveX Data Objects (ADO) technology, but was changed so extensively that it can be considered an entirely new product from microsoft.
10
“ADO .Net Data Providers”
MICROSOFT .NET “ADO .Net Data Providers” ADO.NET allows us to interact with different types of data sources and different types of databases. However, there is not a single set of classes that allow you to accomplish this universally. Since different data sources expose different protocols, we need a way to communicate with the right data source using the right protocol. Then what is Protocol?
11
ADO.NET Data Source/Service Providers
Provider Name Protocol Data Source Description ODBC Data Provider Odbc Data Sources with an ODBC interface. Normally older data bases OleDb Data Provider OleDbData Sources that expose an OleDb interface, i.e. Access or Excel. Oracle Data Provider Oracle For Oracle Databases. SQL Data Provider Sql For interacting with Microsoft SQL Server. Borland Data Provider Bdp Access to many databases such as SQL Server and Oracle
12
MICROSOFT .NET ADO.NET Objects ADO.NET includes many objects (classes) you can use to work with data. The objects below are the ones you must know. Learning about them will give you an idea of the types of things you can do with data when using ADO.NET. The Connection Object To interact with a database, you must have a connection to it. The connection helps identify the database server, the database name, user name, password, and other parameters that are required for connecting to the data base.
13
MICROSOFT .NET Microsoft Visual Studio .NET provides two types of Connection classes in its base class library: The SqlConnection object, which is designed specifically to connect to Microsoft SQL Servers. The OleDbConnection object, which can provide connections to a wide range of database types like Access and Oracle. The Connection object contains all of the information required to open a connection to the database. A connection object is used by command objects so that command object will know on which database the command is to execute.
14
The Command object is represented by two corresponding classes:
MICROSOFT .NET The Command Object: The process of interacting with a database means that you must specify the actions you want to occur. This is done with a command object. You use a command object to send SQL statements to the database. A command object uses a command string(insert, delete, update select) and a connection object to figure out which database to communicate with. The Command object is represented by two corresponding classes: SqlCommand OleDbCommand
15
ExecuteScalar: Returns a single value from a database query.
MICROSOFT .NET The Command objects can be used to execute stored procedures on the database, SQL commands, or return complete tables directly. Command objects provide three methods that are used to execute commands on the database: ExecuteNonQuery: Executes commands that have no return values such as INSERT, UPDATE or DELETE. ExecuteScalar: Returns a single value from a database query. ExecuteReader: Returns a result set (collection of rows or columns or both).
16
MICROSOFT .NET The DataReader Object Many data operations require that you only get a stream of data for reading. The data reader object allows you to obtain the results of a SELECT statement from a command object. For performance reasons, the data returned from a data reader is a fast forward-only stream of data. This means that you can only pull the data from the stream in a sequential and connected manner for reading. This is good for speed, but if you need to manipulation /alteration in data, then a Data Set with Data Adopter is a better object to work with.
17
The DataAdapter Object
MICROSOFT .NET The DataAdapter Object Sometimes you need to caching data in memory to minimize the number of database calls for data. The data adapter makes it easy for you to accomplish these things by helping to manage data in a disconnected mode. The data adapter adopts the data and fills a DataSet object.
18
MICROSOFT .NET The Dataset Object “The dataset is a disconnected, in-memory representation of data and the data in it can be manipulated and updated independent of the database”. When the use of this DataSet is finished, changes can be made back to the central database for updating. The data in DataSet can be loaded from any valid data source like Microsoft SQL server database, an Oracle database or from a Microsoft Access database. The DataSet is specifically designed to help manage data in memory and to support disconnected operations on data.
19
MICROSOFT .NET DataSet can be considered as a local copy of the relevant portions of the database. They contain multiple Datatable objects, which contain columns and rows, just like normal database tables. You can even define relations between Data tables to create parent-child relationships in a dataset.
20
Summary: ADO.NET is the .NET technology for interacting with data sources. You have several Data Providers, which allow communication with different data sources, depending on what the database is. Regardless, of which Data Provider used, you'll use a similar set of objects to interact with a data source. The SqlConnection object lets you manage a connection to a data Source. SqlCommand objects allow you to talk to a data source and send commands to it. To have fast forward-only read access to data, use the SqlDataReader. If you want to work with disconnected data, use a DataSet and implement reading and writing to/from the data source with the help of a SqlDataAdapter. MICROSOFT .NET
21
MICROSOFT .NET Any Query?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.