Getting a Return Value from a Stored Procedure


Author
Message
Terry Bottorff
Terry Bottorff
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 448, Visits: 12K
I have the following Stored Proc (I am not sure it is correct). I just am trying to see if there are any duplicates in the table.

CREATE PROCEDURE [dbo].[sp_CountSRStockforDups] 
   -- Add the parameters for the stored procedure here
   @myRowCount int = 0 OUTPUT
AS
BEGIN
   -- SET NOCOUNT ON added to prevent extra result sets from
   -- interfering with SELECT statements.
   SET NOCOUNT ON;

    -- Insert statements for procedure here
   select stock, count(stock) as pen from dbo.SRstocks where stock > 0 group by stock having (count(stock)) > 1
   select @myRowCount = @@ROWCOUNT
   return @myRowCount
END

I know I have 2 records that repeat but with the following code it returns zero(0).?
        Dim nret As Integer = 1000
                 Dim cmd As New SqlCommand("sp_CountSRStockforDups")
                cmd.CommandType = Data.CommandType.StoredProcedure
                ' OutPut Parameter
                cmd.Parameters.Add("@myRowCount", Data.SqlDbType.Int).Direction = Data.ParameterDirection.Output
                nret = CType(cmd.Parameters("@myRowCount").Value, Integer)
Please understand I am not sure any of this is correct except the attached picture seems to indicate that my stored proc is working but any help would be appreciated. TIA



Attachments
countingstk.png (179 views, 6.00 KB)
Replies
Terry Bottorff
Terry Bottorff
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Is there some where I can find a basic subclass of the BO that has Everything that is needed to make it work so I can start adding some of these functions and not have to do it on Every BO?
Thanks in Advance.
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Terry,

Yes, there are some sample code in the forums, probably Ivan (the Google expert) may provide some links, but basically this what you have to do:
  1. Create a BO class and do not map it to any of your tables.  You could name it whatever you want, I name mine "ApplicationBaseBusinessClass.vb"
  2. Add all the custom, generic code you expect to use in all your BOs like the ones I posted here.  Also if you use some custom field properties in all your BO with the same name, here is a good place to have them all.
  3. In your current and new BO, change the "Inherits" statement from:

     Inherits MicroFour.StrataFrame.Business.BusinessLayer
to
Inherits CardTrackingSystem.Business.ApplicationBaseBusinessClass


Of course in the sample above the namespace "CardTrackingSystem" should be replace with your own NameSpace.  After that, recompile your project and start having fun with your base BO class.

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Terry Bottorff - 15 Years Ago
Ivan George Borges - 15 Years Ago
Terry Bottorff - 15 Years Ago
Terry Bottorff - 15 Years Ago
             You're welcome. :cool:
Ivan George Borges - 15 Years Ago
Edhy Rijo - 15 Years Ago
Trent L. Taylor - 15 Years Ago
Charles R Hankey - 15 Years Ago
Edhy Rijo - 15 Years Ago
                     >> cmd.CommandText= String .Format(...
Charles R Hankey - 15 Years Ago
                         Hi Charles, I had to do the test this time, since it is not...
Edhy Rijo - 15 Years Ago
                             This looks good. Also, if you pass a comma separated list of fields to...
Charles R Hankey - 15 Years Ago
                                 [quote][b]Charles R Hankey (11/29/2010)[/b][hr]This looks good. Also,...
Edhy Rijo - 15 Years Ago
                                     I think your idea of an array for multiple fields is very good,...
Charles R Hankey - 15 Years Ago
                                         [quote][b]Charles R Hankey (11/29/2010)[/b][hr](... reading that over...
Edhy Rijo - 15 Years Ago
Ger Cannoll - 15 Years Ago
Edhy Rijo - 15 Years Ago
Terry Bottorff - 15 Years Ago
Edhy Rijo - 15 Years Ago
Terry Bottorff - 15 Years Ago
Terry Bottorff - 15 Years Ago
Edhy Rijo - 15 Years Ago
Terry Bottorff - 15 Years Ago
Edhy Rijo - 15 Years Ago
Terry Bottorff - 15 Years Ago
Edhy Rijo - 15 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search