Adapter.DeleteCommand.ExecuteNonQuery returns -1 but it works

  • Thread starter Thread starter bogdan
  • Start date Start date
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
 
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.
 
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
 
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.
 
You were absolutely correct. There was SET NOCOUNT ON at the top of the
stored proc.

Thanks,
Bogdan
 
Back
Top