Adapter.DeleteCommand.ExecuteNonQuery returns -1 but it works

B

bogdan

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
 
O

OHM \( One Handed Man \)

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.
 
B

bogdan

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
 
O

OHM \( One Handed Man \)

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.
 
B

bogdan

You were absolutely correct. There was SET NOCOUNT ON at the top of the
stored proc.

Thanks,
Bogdan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top