473,395 Members | 1,484 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Using "rows affected" to manipulate code

Hi,
just a small question. I've just looked at a friends code and he's done this:
int rowsAffected = sql.ExecuteNonQuery("stored_procedure", cmdParams);

if(rowsAffected < 1)
{
return false;
}
else
{.......
}

of course the code broke as soon as i put SET NOCOUNT ON in the sp..

is there a better way to check if any rows have been affected?

Thank you
Kiki
Nov 16 '05 #1
2 4290
You need to get that info back one way or the other. If you just pull a
datatable/dataset back you can check the Rows.Count property of the given
table. But for updates, you need to either use what he did or specify an
output parameter or return value. Check out www.betav.com -> Articles->
MSDN - Retrieving the Gozoutas - Bill Vaughn has a great discussion of this.

HTH,

Bill
"Kiki" <ki**@dyky.co.uk> wrote in message
news:85*************************@posting.google.co m...
Hi,
just a small question. I've just looked at a friends code and he's done this: int rowsAffected = sql.ExecuteNonQuery("stored_procedure", cmdParams);

if(rowsAffected < 1)
{
return false;
}
else
{.......
}

of course the code broke as soon as i put SET NOCOUNT ON in the sp..

is there a better way to check if any rows have been affected?

Thank you
Kiki

Nov 16 '05 #2
"Kiki" <ki**@dyky.co.uk> wrote:
is there a better way to check if any rows have
been affected?


The SqlDataReader class has a RecordsAffected property.

P.
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Chris Stromberger | last post by:
When issuing updates in mysql (in the console window), mysql will tell you if any rows matched and how many rows were updated (see below). I know how to get number of rows udpated using MySQLdb,...
1
by: Max | last post by:
Hello everybody, I have a problem with javascript. Basically I have a frame that is split with this code: <frameset rows="0,*"> <frame name="top" src="nothing.html"> <frame name="center"...
3
by: Andy Fish | last post by:
Hi, when there are no rows to display in my asp.net datagrid control, I'd like to put in a message saying "No results" or some such Ideally I'd like the message to be centred across all the...
6
by: phonl | last post by:
In ADO2, how would I find the position of "x" in: myDataSet.Tables("myTable").Rows(x).Item("myField") = "NewValue" I want to manipulate some data in the current row in my dataset, but it seems...
0
by: romancoelho | last post by:
Hey everyone, I know this has to be simple, but can't figure out how to do it. How can I display the grid lines in all rows in the gird. The default behavior of the DataGridView seems to be that it...
17
by: pbd22 | last post by:
Hi. How does one return a range of rows. I know that "Top 5" will return rows 0 - 5 but, how do I get 6 - 10? thanks
3
by: Carl K | last post by:
using MySQLdb, I do cursor.execute("update...") How can I tell how many rows were affected ? Carl K
3
by: nkoriginal | last post by:
Hi: I want to create an store procedure for an ASP page. I've a form with 100 fields and I want to insert the information in: 1) one table with 100 rows or 2) in 5 tables Now, my idea is...
8
by: phub11 | last post by:
Hi - I have a function which appends row(s) to the bottom of a table: function mouseUpHandler() { var table = document.getElementById("mytable"); var rowCount = table.rows.length; var...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.