?
Solved

C# return updated rows

Posted on 2006-05-03
8
Medium Priority
?
310 Views
Last Modified: 2010-04-16
I am using

command.ExecuteNonQuery()


is there anyway to have it return the 1st fields of the updated table.

0
Comment
Question by:bman9111
  • 3
  • 2
  • 2
7 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 150 total points
ID: 16599310
not with the ExecuteNonQuery.

Anyhow, you have to give more details about what you are trying to achieve...
0
 
LVL 8

Author Comment

by:bman9111
ID: 16600024
I am running a global update to a table. and wanted to see what records were touched...I know u can have it return rows affected...

The only other way that I can see is do a select query of the data then through the reader do an update and save to a variable the records touched...I really just wanted to run one sql command which is the update command and that was it...


0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16600052
if you only want to know the number of rows affected, the ExecuteNonQuery has an overload which accepts a parameter that returns that information.

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 8

Author Comment

by:bman9111
ID: 16600310
can u tell me how it would do that ...All i want is the 1st field listing or affected rows...thats it...

0
 
LVL 5

Expert Comment

by:wlfs
ID: 16602513
0
 
LVL 8

Author Comment

by:bman9111
ID: 16604757
so there is no way to have it return the 1st field data of the number of affected rows???

meaning if I have the following


field1     field2
dog        pet
cat         pet
gate       part

and the update script update the fields dog and cat...

that after the update command the return values would be
dog
cat

0
 
LVL 5

Expert Comment

by:wlfs
ID: 16604830
I want to confirm angelIIIs statement: This is NOT possible with ExecuteNonQuery().

What you want IS a query. You can't use NON-query at one hand, and expect it to behave like a query on the other hand :)

I strongly assume that you have a where-clause in your sql-statement to ExecuteNonQuery(). Thus, I suggest you do your ExecuteNonQuery() and then, as a second step, perform a query with the same where-clause. That will return you the data of the affected rows.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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 describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

807 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