Google News
logo
ADO.NET - Interview Questions
What are the different execute() methods available in ADO.NET?
Different execute() methods supported by SqlCommandObject in ADO.NET is given below :
 
ExecuteScalar() : This method returns only a single value from the first row and first column of the ResultSet after the execution of the query. Even if ResultSet is having more than one row or column, all those rows and columns will be ignored. If the ResultSet is empty, it will return NULL.

ExecuteNonQuery() : This method returns the number of rows affected by the execution of a query. This method is not useful to return the ResultSet.

ExecuteReader() : This method returns an object of DataReader which is a read-only and forward-only ResultSet. It needs a live connection with the Data Source. We cannot directly instantiate the DataReader object. A valid DataReader object can be created with the help of the ExecuteReader() method.

ExecuteXmlReader() : This method builds an object of the XmlReader class and will return the ResultSet in the form of an XML document. This method is made available in SQL Server 2000 or later.
Advertisement