Saturday, July 21, 2007

ADO.net Executing Command ExecuteScalar, ExecuteNonQuery ExecuteReader

Each data provider included with the .net framework has its own command object
Every command object inherits from class DbCommand
Providers and their command objects are as under:
OLE DB : OleDbCommand
SQL Server : SqlCommand
ODBC Command : OdbcCommand
Oracle : OracleCommand

Methods common to these providers are:
ExecuteReader : Returns a DataReader object

ExecuteScalar : Returns a single scalar value
ExecuteScalar is used to retrieve a single value (like avg, max, min)

ExecuteNonQuery : Execute a command that does not return any value
ExecuteNonQuery returns no rows
It returns the number of rows affected
Used for Update, Insert, Delete

ExecuteXMLReader : Returns an XMLReader

No comments:

Post a Comment