Can Prepared statemnet returns int value C#

Posted on 2006-11-20
Last Modified: 2012-06-27

When we update the record in the database using prepared statement with the below code.


Can we get some integer or some other value in string or int.


int status = command.ExecuteNonQuery();

Is this Ok or there is some other way to do this using prepared satement

Thanks in Advance
Question by:dinesh_bali
  • 2
LVL 22

Expert Comment

ID: 17984291
By definition, it returns the number of rows effected.  Combine with a try/catch to handle errors.

int numrows=0;
try {
catch (Exception uhoh)
         // oops

Accepted Solution

seazium earned 250 total points
ID: 17984873
ya ..,
command.ExecuteNonQuery();   ----> returns the integer value

int r_count = command.ExecuteNonQuery();  // will be OK

and also.., MSDN defines this as  ;

LVL 22

Expert Comment

ID: 17989236
Don't forget the try/catch

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MediaHelp 4 26
C# bracket error 3 36
updating order of the rows, N+1 query issue, C#,, MVC, SQL Server 3 34
C# Service FileSystemwatcher isse 9 24
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question