C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
31
Reply
What are the Methods of Commands in ADO.NET ?
Naitik Jani
10y
27.3k
1
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
They are used to connect a Connection object to a DataReader or DataSet. Following are the methods provided by a Command object:ExecuteNonQuery: Executes the command defined in the CommandText property against the connection defined in the Connection property for a query that does not return any row (an UPDATE, DELETE, or INSERT). Returns an Integer indicating the number of rows affected by the query.ExecuteReader: Executes the command defined in the CommandText property against the connection defined in the Connection property. Returns a "reader" object that is connected to the resulting row set within the database, allowing the rows to be retrieved.ExecuteScalar: Executes the command defined in the CommandText property against the connection defined in the Connection property. Returns only a single value (effectively the first column of the first row of the resulting row set, any other returned columns and rows are discarded). It is fast and efficient when only a "singleton" value is required.
Mohan G
10y
6
SQL Command Class having three types of methods in ADO.Net==>1) ExecuteNonQuery(); [Integer return type] return number of effected rows by DML Statement.2) ExecuteReader(); [SQl DataReader return type] Holds n-number of rows collection till the connection state is open. 3) ExecuteScaler(); [object return type] return a single cells value from the result of 'Select' statement.
Ravi Shekhar Vishwakarma
10y
3
ExexuteNonQueryExecuteScalerExecuteReader
Anand Jee
10y
2
ExecuteNonQuery: This command method is used for other than select query. For inserting, updating and deleting.ExecuteScalar: This command method used to return single value of a first column record.ExecuteReader: This command method is used to read more than one records from a database.
Alok Gupta
10y
2
ExexuteNonQueryExecuteScalerExecuteReader
Rahul Prajapat
10y
2
ExecuteNonQuery: This command method is used for other than select query. For inserting, updating and deleting.ExecuteScalar: This command method used to return single value of a first column record.ExecuteReader: This command method is used to read more than one records from a database.
sridhar thota
10y
2
ExexuteNonQueryExecuteScalerExecuteReader
Pankaj Kumar Choudhary
10y
2
ExecuteNonQuery ExecuteScalar ExecuteReader
Naitik Jani
10y
2
ExecuteReder,ExecuteNonQuery,ExecuteScaler
VIKAS GUPTA
8y
1
ExecuteNonQuery ExecuteScalar, ExecuteReader
Sreekanth Reddy
10y
1
1)ExecuteNonQuery:-This method executes the command specifies and returns the number of rows affected 2)ExecuteScaler:-returns the first column of first row of the result set. 3) ExecuteReader:-return the set of rows
Vamsi Krishna
10y
1
General methods of Command Class are ExecuteNonQuery(); ExecuteScalar(); ExecuteReader(); are the three main methods of Command class.
Srinivas Pabballa
10y
1
ExexuteNonQueryExecuteScalerExecuteReaderFill
vinoth kumar
10y
1
ExexuteNonQueryExecuteScalerExecuteReaderFill
vinoth kumar
10y
1
ExecuteNonQuery ExecuteReader ExecuteScalar Cancel Clone GetType
Sreekanth Reddy
10y
1
Methods of commands in ADO.NET ExecuteNonQuery ExecuteReader ExecuteScalar
Yatendra Sharma
10y
1
ExecuteNonQuery() : Doesn't return any data but returns affected row count. Return type is integer.ExecuteScalar Method(): It returns the value only in the first column of the first row. Return type is object. ExecuteReader(): It returns a DataReader object.ExecuteXMLReader(): It returns a XMLReader object.
Sujeet Suman
10y
1
The following are the most commonly used methods of the SqlCommand class. ExecuteReader - Use when the T-SQL statement returns more than a single value. For example, if the query returns rows of data. ExecuteNonQuery - Use when you want to perform an Insert, Update or Delete operation ExecuteScalar - Use when the query returns a single(scalar) value. For example, queries that return the total number of rows in a table.
Jaipal Reddy
10y
1
Execute Non Query :-Executes the command defined in the command text property against the connection defined in the connection property for a query that does not return any row (Insert, Update or Delete).Returns an integer indicating the number of rows affected by the query. Execute Reader :- Executes the command defined in the command text property against the connection defined in the connection property.Returns a reader object that in connected to the resulting row set within the data base, allowing the rows to be retrieved. Execute Scalar :-Executes the command defined in the command text property against the column defined in the connection property.Returns only single value the first column of the first row of the resulting row set any other returned columns and rows are discarded.
Munesh Sharma
10y
1
ExecuteNonQuery ExecuteScalar ExecuteReader
MD SHAMSE ALAM
10y
1
ExecuteNonQuery() ExecuteScalar() ExecuteReader()
bharat aggarwal
10y
1
1.ExecuteNonQuery: This method executes the command specifies and returns the number of rows affected. 2.ExecuteReader: The ExecuteReader method executes the command specified and returns an instance of instance of SqlDataReader class. 3.ExecuteScalar: This method executes the command specified and returns the first column of first row of the result set. The remaining rows and column are ignored. 4.ExecuteXMLReader: This method executes the command specified and returns an instance of XmlReader class. This method can be used to return the result set in the form of an XML document
Neeraj Kumar
10y
1
ExecuteReader : Returns a DataReader object. ExecuteScalar : Returns a single scalar value. ExecuteNonQuery : Executes a command that does not return any rows. ExecuteXMLReader : Returns an XmlReader. Available for a SqlCommand object only.
Nanhe Siddique
10y
1
Hello Naitik,As per as Command object is concern i come up with Important properties and method listed below.Properies : 1) CommandText2) CommandType3) CommandTimeout4) Connection.5) DbConnection. Methods : 1) ExecuteNonQuery.2) ExecuteScalar.3) ExecuteReaderFor more information go to visual studio whatever version you have and take a reference of System.Data.SqlClient and create a object of SqlCommand object right client on class and select "Go to defination" or press F12 then you will find everything.
Vaibhav Salwe
10y
1
ExecuteNonQuery : Insert ,Update and DeleteExecuteScalar : Select (For Single Value return)ExecuteReader :Select
Mahendra
10y
1
SQL Command Class having three methods in ADO.Net i.e.1)ExecuteNonQuery() [Integer return type] on DML Statement 2)ExecuteScaler() [Object return type] Use Select Command 3)ExecuteReader() [SQL Data Reader return type] Holdes n-number of rows collection till the connection satae is open
Ravi Shekhar Vishwakarma
10y
1
ExecuteNonQueryExecuteScalarExecuteReader
kishorevemuri v
10y
1
The Command Object in ADO.NET executes SQL statements and Stored Procedures against the data source specified in the C# Connection Object. The Command Object requires an instance of a C# Connection Object for executing the SQL statements .In order to retrieve a resultset or execute an SQL statement against a Data Source , first you have to create a Connection Object and open a connection to the Data Source specified in the connection string. Next step is to assign the open connection to the connection property of the Command Object . Then the Command Object can execute the SQL statements. After the execution of the SQl statement, the Command Object will return a result set . We can retrieve the result set using a Data Reader .
Rajkiran Swain
10y
1
ExecuteNonQuery ExecuteScalar ExecuteReader
Rahul Kr
10y
1
-> ExecuteNonQuery-> ExecuteScalar-> ExecuteReader
Nirav Vasoya
10y
1
ExecuteNonQuery ExecuteReader ExecuteScalar
Anshul Gupta
10y
1
Message