--About ADO .Net--
What is ADO .Net?
Ado .Net Architeture:-
DAO(Data Access Object)-first database connectivity provided by Microsoft which is a library.
RDO(Remote Data Object)-Then RDO came.
ADO-Then ADO came.
ADO.NET-Then ADO.NET came.
These all are library which provides standard.
DAO-Front end and back end must be in single system-means stand alone application.
RDO-Front end and back end can be kept in different locations.
ADO-It came in 1993, has less classes to connect with the database than the RDO so that complexity is being removed in ADO.--Supports connected architecture which requires continuous connectivity. When data changes very frequently then we require connected architecture. ADO support call by reference.
ADO.NET- It came in 2000, It supports connected architecture and disconnected architecture also.(Disconnected Architecture-which supports call by value).
It has polymorphic nature because it can act as connected as well as disconnected architecture.
It can work as an online as well as offline mode.
It supports N-Tier architecture or Distributed architecture.
Disconnected Architecture is used for Ease the overhead of database.
ADO-> ADO.DLL which is ADO Library, which Supports COM(Entry is made in--c:\windows\system32).
Does not support portability(regsvr32 dll_name-command to register the dll in registry but only if we have system admin rights).
These are the legacy(Means a word file which is made on Windows OS is not run on Linux OS but a text file can run in both or any OS). Language is Binary or Machine Language.
ADO.NET-> System.Data.Dll which is ADO.NET library,which supports Assembly(Entry is made id--c:\windows\.net\framework\v.2.0.).
Language is IL(understood by CLR).
ADO-> Connected Architecture-Cursor is a kind of memory from which we can fetch data row by row, which was made on the server side in connected architecture.
Record set is a server side cursor. We have to require constant or continuous connection.
ADO.NET-> Disconnected Architecture-not required continuous connection. A client side cursor is made. Data set is a client side cursor. Data reader is a server side cursor.
DataSet supports XML format.
Distributed Architecture-C#+ADO.NET+Dataset.
Web Service-Does not provide security.
WCF-Provide security.
ADO.NET:-
By using the .net we can develop only front end because it provides a platform for developing the applications.
It provides a shared library which has several namespaces.
It act as a middlemen between the front end and back end.(so that two differnet languages can communicate with each other).C# language and Sql Query language
Ado .Net Architeture:-
System.Data.DLL
System(Namespace)
Console(class)
Array
Data
** DataSet
** DataTable
DataRow
DataColumn
** DataView
Relations
DataConstraint
etc....
SqlClient
SqlConnection
SqlCommand
SqlDataReader
** SqlDataAdapter
** SqlTransaction
SqlCommandBuilder
** SqlParameter
** Parameters
SqlBulkCopy
Front End ADO.NET Back End
ConsoleWindow,Web SqlServer
C#/vb.net Database
ADO.NET:-
1. It provides library(System.Data.DLL)which is having a namespace(SqlClient), consist several classes.
SqlConnection
SqlCommand
SqlDataReader
Initially, we need SqlConnection, SqlCommand, SqlDataReader classes to connect to backend.
What is SqlConnection class:-
SqlConnection class plays a major role to connect with database.
--Important function of this class-
--> Open()
--> Close()
--> BeginTransaction()
--> Dispose()
etc....
What is SqlCommand class:-
Once we connected to a database by SqlConnection class, then we need to perform some operations.
save,update,delete,search,sum,avg,max,min etc...
This above operations is performed by SqlCommand class.
--Important functions of this class-
--> ExecuteNonQuery()--is used for Transactional statement(insert,update,delete)
--> ExecuteReader()--is used for performing fetching of records(Retrieval)
--> ExecuteScalar()--is used for performing the Aggregation or calculations(sum,min,etc...)
etc....
What is SqlDataReader class:-
using this class we can fetch the record by its function called read() Various functions are-
Read()
NextResult()
various properties are-
HasRows
FieldCount
RecordAffected
--ExecuteNonQuery--
We can use the ExecuteNonQuery to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables), or to change the data in a database without using a DataSet
by executing UPDATE, INSERT, or DELETE statements.
Although the ExecuteNonQuery returns no rows, any output parameters or return values mapped to parameters are populated with data.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. When a trigger exists on a table being inserted or updated, the return value includes the number of rows
affected by both the insert or update operation and the number of rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.
--ExecuteScalar--
Use the ExecuteScalar method to retrieve a single value (for example, an aggregate value) from a database. This requires less code than using the ExecuteReader method, and then performing the operations that you need to generate the single value using the data returned by a SqlDataReader.
--ExecuteReader--
ExecuteReader retuns the base address of table. Read is a member function of SqlDataReader class which returns true or false.
Nice blog sir
ReplyDelete