Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Adapter.DeleteCommand.ExecuteNonQuery returns -1 but it works

2 views
Skip to first unread message

bogdan

unread,
Apr 27, 2008, 4:17:18 PM4/27/08
to
Hi,

I have a stored procedure that deletes a record in db. I created a DataSet
(xsd) which auto-generated code for a table adapter. The adapter's select,
insert, update, and delete methods work fine except for one 'minor' problem
with Delete(). The method returns -1 although it does the job - i.e.
deletes a record from database.

Could someone please explain what a possible cause might be? I could ignore
the return value but then I would not be able to detect the true failure.
Also, I'm not sure if this is a sign of some other and more serious
problems.

Thanks,
Bogdan


OHM ( One Handed Man )

unread,
Apr 27, 2008, 5:55:04 PM4/27/08
to
Can you execute the stored proc from SQL Server Studio manager and observe
the result . If it is -1 then you need to post the stored proc code. Else
you might be calling the proc with the wrong type of execution call from
.NET.


"bogdan" <bog...@nospam.com> wrote in message
news:O6HTsNKq...@TK2MSFTNGP05.phx.gbl...

bogdan

unread,
Apr 27, 2008, 6:39:43 PM4/27/08
to
Thanks for the reply.

The stored proc works from outside of asp.net (command line, studio, another
non-asp.net app).
No warnings/errors when executed from the studio.

Could you elaborate on "... calling the proc with the wrong type..." ?

Again, what is weird is that the call succeeds - i.e. the target record is
deleted from the database.

Thanks,
Bogdan

"OHM ( One Handed Man )" <m...@myplace.com> wrote in message
news:%23zQ75GL...@TK2MSFTNGP02.phx.gbl...

OHM ( One Handed Man )

unread,
Apr 27, 2008, 6:43:59 PM4/27/08
to
It may be simply that the server is not returnning the number of rows
affected, which is the value you actually need. More than likely its your
stored proc which is to blame.

"bogdan" <bog...@nospam.com> wrote in message

news:Osj8SdLq...@TK2MSFTNGP03.phx.gbl...

bogdan

unread,
Apr 28, 2008, 9:49:35 AM4/28/08
to
You were absolutely correct. There was SET NOCOUNT ON at the top of the
stored proc.

Thanks,
Bogdan

"OHM ( One Handed Man )" <m...@myplace.com> wrote in message

news:uwXcPiLq...@TK2MSFTNGP06.phx.gbl...

0 new messages