none
ExecuteNonQuery RRS feed

  • Question

  • Hi,


    me little detailed person...:-)

    wanna know the expansion for 'Non' in 'ExecuteNonQuery'....ExecuteNonQuery will run a sql query adn return the results.... why it is called 'NonQuery'?

    Thursday, November 3, 2011 5:40 PM

Answers

  • Santhi,

    ExecuteNonQuery will execute any SQL statement, but it is designed for, and only useful for, UPDATE/DELETE/INSERT sql statements.  It's designed to return the number of rows affected by these.

    Now, it could execute a SELECT query, but it would be rather useless because it couldn't handle the rows that returned and in fact I don't even think it would report even the number of rows returned. 

    For this reason,it's called ExecuteNonQuery.  Because it is designed to execute something that is NOT a query (meaning, not a select statment that is returning rows). 

     


    Tom Overton
    Thursday, November 3, 2011 5:57 PM
  • see the following disucssion:

    http://stackoverflow.com/questions/2834049/why-the-non-in-executenonquery


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, November 3, 2011 6:01 PM
    Moderator

All replies

  • Santhi,

    ExecuteNonQuery will execute any SQL statement, but it is designed for, and only useful for, UPDATE/DELETE/INSERT sql statements.  It's designed to return the number of rows affected by these.

    Now, it could execute a SELECT query, but it would be rather useless because it couldn't handle the rows that returned and in fact I don't even think it would report even the number of rows returned. 

    For this reason,it's called ExecuteNonQuery.  Because it is designed to execute something that is NOT a query (meaning, not a select statment that is returning rows). 

     


    Tom Overton
    Thursday, November 3, 2011 5:57 PM
  • see the following disucssion:

    http://stackoverflow.com/questions/2834049/why-the-non-in-executenonquery


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, November 3, 2011 6:01 PM
    Moderator
  • Thanks Tom and Julia!

     

    I am going to give my own expansion.... 'NON' - No Output Needed'

     

    Ha ha ha...

    Thursday, November 3, 2011 6:06 PM
  • Good one Santhi! That's exactly when it's needed ;)
    Tom Overton
    Thursday, November 3, 2011 6:08 PM