Sunteți pe pagina 1din 2

Command: Class that creates a command object which will help to execute sql

statements, stored procedure against the data source. In order to execute a sql statement,
steps to be followed:
1. Open a connection to the data source.
2. ssign the connection to the connection propert! of the command object.
". #hen command object will execute the statement.
$. %eturn the result in a result set.
&. #hen we retrie'e result set using (ata%eader.
SqlCommand cmd=new SqlCommand(select * from tablename,con);
)our methods for executing quer! inside the command:
1. *xecute+on,uer!-.: used for executing statements that don/t return an! rows0result
sets. It performs mainl! data manipulation and data definition.
(ata manipulation tas12 insert, update, delete
(ata definition tas12 creating stored procedure, 'iew
2. *xecute%eader-.: used when queries return an! number of queries. i.e. in case of
select, statement, retrie'al.
". *xecute3calar-.: queries that return a single 'alue, i.e. count, a'g, sum, min etc.
$. *xecute4ml%eader-.: to read an! 456 file stored in (7.
DataReader: 8elps to get or to retrie'e the data and after retrie'ing the data from the
database stores the data in the networ1 buffer of computer client and remains there until we
request the data to displa! with the help of read method %ead-..
ExecuteReader() sends the sql commands to the 3qlConnection objects and populate the
SqlDataReader object based on sql statements. 9hen the *xecute%eader-. execute, it
instantiate a 3ql(ata%eader object. #he %ead-. in the (ata%eader used to read the rows from
(ata%eader and alwa!s mo'es forward to a new 'alid row. *.g.:
SqlDataReader dr ;
dr= cmd.ExecuteReader() ;
f(dr.read())!
txt".text= dr.#et$nt%&(') ;
(
DataSet: (ataset is the core architecture of disconnected mode of (O.+et. Once we
retrie'e the data from the database, we can manipulate that data in disconnected mode.
(ataset manages the retrie'al of data which become local to the application. (ataset is
mainl! a container that contains collection of data tables and a data table is the collection of
all tuples. :sing dataset we can retrie'e data from multiple tables. (ataset doesn/t ha'e an!
direct connection; the! retrie'e the data from database using (atadapter.
Data)da*ter: (atadapter is a part of (O.+et. (atadapter pro'ides communication
b! using +ll method which ma1es the changes in the (ata3et to match the data in data
source and update the data source to match data in (ata3et.
1. )irst we establish connection from aspx page b! using 3ql(ata3ource.
2. Connection established and 9eb.config file created which will contain connection
string. 9e can change the name of connection string for our use.
". #hen go to 3<4 page and write the button !ou want to create.
$. %ight clic1 on button, go to properties, clic1 on e'ent and double clic1ing on the name
of e'ent will go straight to aspx.cs page where we will write the code.
Conf,uraton-ana,er: Configuration5anager is the class which is used extract
default configuration from the 9eb.config such as to extract the connection string from the
9eb.config file.
Strn, str= Conf,uraton-ana,er.ConnectonStrn,s.mancon/.0oStrn,; 11Connection string

S-ar putea să vă placă și