1 / 27

ADO.NET

ADO.NET. ADO.NET. ADO.NET deals with accessing and manipulating databases.it comprises of many namespaces and classes to do so. ADO.NET provides access to datasources such as Microsoft SQL server,OLE DB and XML.

atalo
Download Presentation

ADO.NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ADO.NET

  2. ADO.NET • ADO.NET deals with accessing and manipulating databases.it comprises of many namespaces and classes to do so. • ADO.NET provides access to datasources such as Microsoft SQL server,OLE DB and XML. • Application written in .NET compliant languages connect to these datasources to access manipulate or update the data

  3. ADO(activeX data objects) • ADO relied on a connection based mode.in the connection approach ,the client had to be connected with the server(data source) and remain connected till the whole procedure or transaction was copleted.in such approach a lot of bandwidth was required. • If 100 clients were to use a server,each would need a connection. • Time ,resources and bandwidth became a major constraint on such architecture.

  4. To solve this problem latest version of ADO used record sets, All the content from the datasource was coppied from data source to record set..This allowed the client to get disconnected from the server,work on the record set and copy the changes back to data source again. • It required COM marshalling to transmit disconnected data,it support only COM supported data types and it required type conversion.

  5. ADO • Microsoft's ActiveX Data Objects (ADO) is a set of Component Object Model (COM) objects for accessing data sources. it provides a middleware layer between programming languages and OLE DB (a means of accessing data stores, whether they be databases or otherwise, in a uniform manner). ADO allows a developer to write programs that access data without knowing how the database is implemented. He must be aware of the database for connection only. No knowledge of SQL is required to access a database when using ADO, although one can use ADO to directly execute SQL commands. The disadvantage of the latter is that it introduces a dependency upon the type of database used.

  6. Basic Usage • Create a connection object to connect to the database. • Create a recordset object in order to receive data in. • Open the connection • Populate the recordset by opening it and passing the desired table name or SQL statement as a parameter to open function. • Do all the desired searching/processing on the fetched data. • Commit the changes you made to the data (if any) by using Update or UpdateBatch methods. • Close the recordset • Close the connection

  7. ADO.NET • ADO.NET (ActiveX Data Object for .NET) is a set of computer software components that programmers can use to access data and data services. It is 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. 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..

  8. ADO.NET • ADO.NET supports both disconected and connected approach.In majority of situations disconected approach is used ,in this approach transmission of data is in XML format.XML format places no restriction on the datatypes and require no type conversion.

  9. WCF Data services • WCF Data Services (formerly ADO.NET Data Services, codename "Astoria") is a platform for what Microsoft calls Data Services. It is actually a combination of the runtime and a web service through which the services are exposed.

  10. ADO.NET COMPONENTS • DATA SET • .NET DATA Providers Is used for connecting to the database,executing commands and retreivingresults.we can either access database directly or use the disconectedapproach.For the disconected approach we use the DATASET class.

  11. .NET Data Providers • A Data provider consists of following basic objects • A connection object • A command object • A DataReader object • A dataAdapter object

  12. Connection object • The connection object is used to connect to the data source.Data source can be any database file.The connection object contains the information like the provider name,server name, data source name,username,password and so on/

  13. Command object • A command object is used to connect the connection object to a DataReader or DataAdapterobject.The command object allows us to execute an SQL statement or stored procedures in a data source

  14. DataReader • The DataReader is used to read the data in a fast and efficient manner from the database.. It is generally used to extract one or a few records or a specific field value or to execute simple SQL statements.

  15. DataAdapter object A DataAdapter is used to fill data from the database into the Dataset object.ThedataAdater is used in disconnected approach.

  16. .NET Data providers • OLE DB .NET PROVIDER (MICROSOFT ACCESS) • SQL SERVER .NET PROVIDER

  17. Create a database • Create a database in access and name it “bank”. • Create a table and name it “account” • It should be like the next slide. • And fill it with appropriate data.

  18. Now fill the data like this

  19. Question of today ? • Write a program to access these values and print them using ADO.NET Objects ?

  20. Create an empty web site named it “bank” • Add a web page account.aspx in solution explorer.

  21. DataSets • ADO.NET imlements the disconected approach using the Dataset class.In the disconnected approach connection is established ,the data from the database is copied to the cache and then connection is closed.Next we manipulate the data in the cache and then connect back to restore the data in the database.This approach saves time and resources.

  22. Dataset class • The dataset class is designed for dataaccess independent of the .NET Data Providers.it means that it does not matter whether we are using the SQL .net OR the OLE DB .NET provider .we can use the same class for both the providers.TheDataSet class provides methods and properties to access the tables,rows and columns of the data source.

  23. Datset (continued) • A dataset object can hold more than one table from the datasource.it can also hold the relationship that exist between the table in the dataset.

  24. Binding the GridView • We must bind the grid view control to some data source.the control then automatically displays the records of the specified table

  25. Quiz(dat access layer) Q1 C eate a project and connect it to the databasd (Northwind). and create a DAL layer.(1) Issuing SELECT, INSERT, UPDATE, and DELETE commands, and so on – should be located in the DAL. The presentation layer (your web page)should not contain any references to such data access code, but should instead make calls into the DAL for any and all data requests. Data Access Layers typically contain methods for accessing the underlying database data. The Northwind database, for example, has Products and Categories tables that record the products for sale and the categories to which they belong. In our DAL You will have methods like: 2)GetCategories(), which will return information about all of the categories 3) GetProducts(), which will return information about all of the products 4) GetProductsByCategoryID(categoryID), which will return all products that belong to a specified category 5) GetProductByProductID(productID), which will return information about a particular product Q2)what is the difference between loosely typed objects and strongly typed objects.why this approach (DAL)is prefferable over using DatsSource controls directly. MAIL IT(alnasrkhan@gmail.com)

More Related