what is different between SqlCommand object and Command
Behaviour Object

Answers were Sorted based on User's Feedback



what is different between SqlCommand object and Command Behaviour Object..

Answer / sudhir kumar pal

ADO.NET Command Object - The Command object is similar to
the old ADO command object. It is used to store SQL
statements that need to be executed against a data source.
The Command object can execute SELECT statements, INSERT,
UPDATE, or DELETE statements, stored procedures, or any
other statement understood by the database. See sample
code...

'Code below in VB.NET ...
Dim ObjCom as SqlClient.SqlCommand
ObjCom.SqlConnection(strCon)
ObjCom.Connection.Open()
ObjCom.CommandText = "Select * from tblSample"
ObjCom.ExecuteNonQuery()


SqlCommand objects are not used much when we use datasets
and data adapters. Following are some properties of the
SqlCommand class...

Is This Answer Correct ?    9 Yes 2 No

what is different between SqlCommand object and Command Behaviour Object..

Answer / gyany

CommandBehaviour:-
Provides a description of the results of the query and its
effect on the database.
Like,
To Forcibly close the Connection=
Command cmd=new Command
("SQL",conn,CommandBehaviour.CloseConnection);

Is This Answer Correct ?    7 Yes 1 No

what is different between SqlCommand object and Command Behaviour Object..

Answer / kiranmadiraju

SqlCommand is used to store a SQL command/Name of the
stored procedure along with parameter collection to execute
against the datastore

Whereas CommandBehaviour provides the description of
results of the query and its effect on the database.

The values are like this
1.Default
The query may return multiple result sets. Execution of the
query may affect the database state. Default sets no
System.Data.CommandBehavior flags, so calling ExecuteReader
(CommandBehavior.Default) is functionally equivalent to
calling ExecuteReader().

2.SingleResult
The query returns a single result set.

3.SchemaOnly
The query returns column information only. When using
System.Data.CommandBehavior.SchemaOnly,the .NET Framework
Data Provider for SQL Server precedes the statement being
executed with SET FMTONLY ON.

4.KeyInfo
The query returns column and primary key information.

5.SingleRow
The query is expected to return a single row. Execution of
the query may affect the database state. Some .NET
Framework data providers may, but are not required to, use
this information to optimize the performance of the
command. When you specify
System.Data.CommandBehavior.SingleRow with the
System.Data.OleDb.OleDbCommand.ExecuteReader() method of
the System.Data.OleDb.OleDbCommand
object, the .NET Framework Data Provider for OLE
DB performs binding using
the OLE DB IRow interface if it is available.
Otherwise, it uses the IRowset
interface. If your SQL statement is expected
to return only a single row,
specifying
System.Data.CommandBehavior.SingleRow can also improve
application
performance. It is possible to specify
SingleRow when executing queries that
return multiple result sets. In that case,
multiple result sets are still
returned, but each result set has a single row.

6.SequentialAccess
Provides a way for the DataReader to handle
rows that contain columns with
large binary values. Rather than loading the
entire row, SequentialAccess
enables the DataReader to load data as a
stream. You can then use the GetBytes
or GetChars method to specify a byte location
to start the read operation,
and a limited buffer size for the data being
returned.
7.CloseConnection
When the command is executed, the associated
Connection object is closed
when the associated DataReader object is
closed.

Is This Answer Correct ?    4 Yes 1 No

Post New Answer

More ADO.NET Interview Questions

How we can provide data to ado.net?

0 Answers  


What is the use of SqlCommandBuilder?

0 Answers  


Which method is used to sort the data in ADO.Net?

0 Answers  


What is the difference between statement and preparedstatement interface?

0 Answers  


What are the namespaces used in ado.net for data access?

0 Answers  






What is Dataset Object?

0 Answers  


Does ado.net use odbc?

0 Answers  


Describe connection object in ado.net

0 Answers  


can we change the data in dataset? if yes what is the process?

1 Answers   Artech,


What is an orm, and why would you use one instead of plain old ado.net?

0 Answers  


How can I retrieve two tables of data at a time by using data reader? Data reader read and forward only, how is it possible to get 2 tables of data at a time?

0 Answers  


What is the difference between the clone() and copy() methods of the dataset class?

0 Answers  


Categories