I have read many blogs and articles related to this but i didnt got the answer...
Definition says that, Execute Non Query returns only no. of rows affected and does not return colums or rows of table..
Interviewer always confuse us with this question..
Kindly give proper ans to it!!
Thanks in advance...
Loading
Akkiraju IvaturiPosted Aug 28, 2012, 8:40 AM
Akkiraju IvaturiPosted Aug 29, 2012, 7:52 AM
Dhara MaheshwariPosted Aug 29, 2012, 1:20 AM
Santhosh Kumar JayaramanPosted Aug 28, 2012, 8:18 AM
Even if you use select statment with ExecuteNonquery it will return -1.
Read this line from msdn and check the bolded line. Select statement will fall under other types of statement mentioned here.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers. For all other types of statements, the return value is -1.
Akshay PatelPosted Aug 28, 2012, 8:18 AM