all groups > dotnet ado.net > january 2007 >
You're in the

dotnet ado.net

group:

Getting double count of updated records


Getting double count of updated records David
1/31/2007 12:36:28 PM
dotnet ado.net:
I have an SQL statement that uses the Command method ExecuteNonQuery and it
is returning twice the number of rows (24) actually updated. When I run the
same statement using SQL SELECT I get 12 rows. Below is my ASP.NET SQL
code:

strSQL = "UPDATE File_Mst" & _

" SET CheckedOut = 12345" & _

" WHERE ([BoxNum] Like N'%41644%')" & _

" AND ([CheckedOut] = 0)"


cmdSelect = New SqlCommand(strSQL, conFileData)

intRecsProcessed = cmdSelect.ExecuteNonQuery()

The variable intRecsProcessed is returning a count of 24 but only 12 rows
are affected. Can someone help with this? Thank you.

David

Re: Getting double count of updated records David
1/31/2007 2:21:11 PM
I think I found out why. I have an update trigger on the table that updates
another field on that same table. Does this affect the returned count?
Thanks.

David

[quoted text, click to view]

Re: Getting double count of updated records RobinS
1/31/2007 3:01:01 PM
Yes. If you add "SET NOCOUNT ON" for the update trigger's procedure, I
think it will then *not* return those updated rows in your rowcount.

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
-------------------------------
[quoted text, click to view]

Re: Getting double count of updated records David
2/1/2007 8:24:54 AM
Thanks. I'll try that. That makes sense.

David

[quoted text, click to view]

AddThis Social Bookmark Button