ADO.Net Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 1819 Page Views: 

What is the use of command objects?



Posted By: Avi Date: 15 October 2009 05:03:07 AM
 Answer:

This object represents an SQL statement that is executed while connected to the database. Following are the main methods provided by command object:

1) ExecuteNonQuery:
Executes the SQL query or Stored Procedure that does not return any row (an UPDATE, DELETE, or INSERT). Returns an Integer indicating the number of rows affected by the query.

2) ExecuteReader:
Executes the SQL query or Stored Procedure and returns a DataReader object that is connected to the resulting row set within the database, allowing the rows to be retrieved.

3) ExecuteScalar:
Executes the SQL query or Stored Procedure and returns only single value (effectively the first column of the first row of the resulting row set any other returned columns and rows are discarded).


Posted By: eTechPlanet


Date: 15 October 2009 05:03:07 AM

Use of a Command object to query a database and return to records in a Recordset object, to execute a bulk operation, or to manipulate the structure of a database. Depending on the functionality of the provider, some Command collections, methods, or properties may generate an error when they are referenced.


Posted By: Daniel


Date: 16 February 2010 03:21:49 AM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image D68Gw3
Related Questions
ADO.Net : Can you reuse an exisiting open ADO.NET connection with LINQ to SQL?
ADO.Net : To what type ntext type will be mapped in c# code?

To what type ntext type will be mapped in c# code?

SqlTypes.SqlString
Category: ADO.Net Date: 10/13/2010 8:08:47 PM
ADO.Net : Does Recordset exists in ADO.NET?

Does Recordset exists in ADO.NET?

No
Category: ADO.Net Date: 10/13/2010 7:15:48 PM
ADO.Net : How can you fill data set with multiple tables?

How can you fill data set with multiple tables?

Provide two or more queries separated by ; to SqlDataAdapter and use it to fill dataset.
Category: ADO.Net Date: 10/13/2010 5:21:47 PM
ADO.Net : What class should you use XslTransform or XslCompiledTransform for XSL transformations?

What class should you use XslTransform or XslCompiledTransform for XSL transformations?

XslTransform is newer, faster and have more options and should be used
Category: ADO.Net Date: 10/13/2010 4:29:48 PM