Results 1 to 4 of 4

Thread: (C# and ADO.NET) ExecuteNonQuery() problem

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2002
    Posts
    51

    (C# and ADO.NET) ExecuteNonQuery() problem

    Hi there!

    how I can find out why ExecuteNonQuery() return 0 and not 1 by submit?
    at this moment I see no chance to know why my query isn't submited.


    thx


    gicio

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    ExecuteNonQuery() does not return any rows. You use this when you want to perform insert, update or delete on the table. You should use ExecuteScalar() is you just want a single value.
    Dont gain the world and lose your soul

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Originally posted by DevGrp
    ExecuteNonQuery() does not return any rows. You use this when you want to perform insert, update or delete on the table. You should use ExecuteScalar() is you just want a single value.
    ExecuteNonQuery() returns how many rows were effected.

    gicio, check your sql statement or stored procedure (if you use it).
    Try executing the statement directly against the database and see the outcome.

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    If he just wants to know the affected rows, he can use ExecuteNonQuery() function. As the name suggests. This function does not perform a query against the DB. It just returns the rows that were affected during an update, delete or insert.
    Dont gain the world and lose your soul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width