What is the difference between excute query and excute nonquery.?

Showing Answers 1 - 14 of 14 Answers

B.venkateswara Rao

  • Jun 26th, 2005
 

executequery applies for commands and execute nonquery for insert,update and delete.

vvabbu

  • Jul 22nd, 2005
 

 
ExecuteQuery from command Object 
 
we can use the ExecuteNonQuery to perform catalog operations (Insert,Delete,Update) 
 
ExecuteNonQuery does not return any rows, any output parameters or return values mapped to parameters are populated with data. 
 

yerva

  • Aug 18th, 2006
 

executeQuery() is for command objects i.e., this method will send "select statement" to database and returns value given by the database.

Moreover the executeQuery() is not used in .net but it is used in JAVA.

executeNonQuery() uses the "Insert/Update/Delete/Stored subprogram"  , this method will return number of records effected by the database table

kk

  • Feb 9th, 2007
 

false, it returns rows affected

  Was this answer useful?  Yes

Gunjan Arora

  • Apr 7th, 2007
 

ExecuteQuery() method is in Java and returns SQLServerResultSet object.
SqlCommand.ExecuteNonQuery Method executes a Transact-SQL statement against the connection and returns the number of rows affected.

venkatesan

  • Jul 20th, 2007
 

Execute Query is the Command object. It returns query affected datas,  Execute Non Query is also command object. But It returns No of affected rows value.

bb.geetha

  • Jun 6th, 2008
 

we can use the ExecuteNonQuery to perform catalog operations (Insert,Delete,Update)

ExecuteNonQuery does not return any rows, any output parameters or return values mapped to parameters are populated with data.

executeQuery() is for command objects i.e., this method will send "select statement" to database and returns value given by the database.

  Was this answer useful?  Yes

In ADO.NET we are not using execute query but execute non query is used, when SQL stmt is
 DDL (Create, Alter, Drop stmts), DML (Insert, Delete, Update), stored sub program .

  Was this answer useful?  Yes

In ADO.net for Command Object you have 3 methods
1.ExecuteReader - Select statements
2.ExecuteNonQuery - DML statements(Insert,Update and Delete) - Returns Number of rows affected
3.ExecuteScalar - Returns a single value from Aggregate functions like SUM,AVG,COUNT etc

  Was this answer useful?  Yes

sheetal maheshwari

  • Nov 24th, 2011
 

: execute query is used for DDL commands whereas execute nonquery for DML.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions