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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
About delegates in c sharp 3 50
Video Player 11 23
Hey Audio! 3 30
List<PaisEntity> - show some 1 24
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

831 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