473,770 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ExecuteNonQ uery("stored_pr ocedure", 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 4307
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.u k> wrote in message
news:85******** *************** **@posting.goog le.com...
Hi,
just a small question. I've just looked at a friends code and he's done this: int rowsAffected = sql.ExecuteNonQ uery("stored_pr ocedure", 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.u k> 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
5088
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, but is there any way to get the number of rows matched? I want to find out, when rows updated = 0, if there were no updates because the row wasn't found (rows matched will = 0) or because the update would not have changed any data (rows matched =...
1
2087
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" src="page.html"> </frameset>
3
3874
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 columns, but I'd settle for the message appearing in a single cell, or header/footer line. maybe there's a way to make the whole control invisible when there are no rows in the data source.
6
2265
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 that I have to know the index of the row that my dataset is at. How do I find the index of the current row?
0
2225
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 only shows grid lines around rows that have data in it. If there are not enough rows to fill the height of the grid, then the grid lines don't show up around the "empty rows" I say "empty rows" because there actually a row there. So it seems...
17
4586
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
15992
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
2083
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 create an store procedure for insert BUT if tomorrow I need to add more fields and rows in sql, I would like not touch nothing in my code.
8
2757
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 addRow = table.insertRow(rowCount); addRow.id = cnt; var addCell = addRow.insertCell(1); addCell.id = cnt;
0
9602
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9882
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3987
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.