Diff bet ExecuteReader and ExecuteNonQuery RRS feed

  • Question

  • Hi All,

       Please give me in detail "Differences bet ExecuteReader and ExecuteNonQuery"


    Thursday, August 14, 2008 1:25 AM


  • ExecuteNonQuery:
    Performs commands that change the database but do not return a specific value, including adding and deleting items from a database. The ExecuteNonQuery method returns the number of rows affected by the command.

    Reads records sequentially from the database.The ExecuteReader method performs commands that return records, such as SQL SELECT. Each record is returned as a data reader object, which is sort of a read-only version of a data set. Because the ExecuteReader method acts directly on the database connection, there are two versions of the data reader object: OleDbDataReader and SqlDataReader.
    Using ExecuteReader to create data reader objects provides better performance than creating a data set from a data adapter object, but it doesn’t provide you with much flexibility.

    Mohammad salmaan
    Thursday, August 14, 2008 6:06 AM