Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

Adapter.DeleteCommand.ExecuteNonQuery returns -1 but it works

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bogdan - 27 Apr 2008 21:17 GMT
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 ) - 27 Apr 2008 22:55 GMT
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.

> Hi,
>
[quoted text clipped - 11 lines]
> Thanks,
> Bogdan
bogdan - 27 Apr 2008 23:39 GMT
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

> 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
[quoted text clipped - 16 lines]
>> Thanks,
>> Bogdan
OHM ( One Handed Man ) - 27 Apr 2008 23:43 GMT
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.

> Thanks for the reply.
>
[quoted text clipped - 30 lines]
>>> Thanks,
>>> Bogdan
bogdan - 28 Apr 2008 14:49 GMT
You were absolutely correct.  There was SET NOCOUNT ON at the top of the
stored proc.

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
[quoted text clipped - 34 lines]
>>>> Thanks,
>>>> Bogdan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.