[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

VB.NET and return value from stored procedure

Asked by vj_mi in Microsoft Visual Basic.Net

Tags: return, procedure, value, stored, from

Hello,

Below is the my stored procedure. When I use .ExecuteScalar from VB.NET, I expect the return value from the SP as 0 or 1. But I always get blank i.e. "". Why?


CREATE procedure [dbo].[sp_VoidTransaction_Repost](@intTransactionNr as Integer, @Sales_date as Datetime, @intAccountNr as Integer)
AS

Declare @strSQL as varchar(8000)
Declare @intNewTrnNr as Integer

BEGIN TRANSACTION
-- Insert voided record into Sales Master
Insert Into Sales_Master( ShipNr, Sales_TrnNr, Partial_Sales_Nr,
      ServerID, Table_Nr, Account_Nr, Routing_Account, Transaction_Status, Cabin_Nr, Sales_date,
      Cruise_Nr, Outlet_Nr, Stock_Code, NetSalesPrice, GrossSalesPrice, Gratuity, Discount,
      IsTaxApplicable, TaxType, TaxAmount, Amount_due, IsSalesDeducted_FromStock, Settlement_type,
      Payment_Type, IsSalePartiallyClosed, NewServerID, Extra_Gratuities, isSelected, AIAccount_Nr,
      AllInclusiveDiscount, IsAllInclusive, VoidFlag )
             Select ShipNr, Sales_TrnNr, Partial_Sales_Nr,
      ServerID, Table_Nr, Account_Nr, Routing_Account, Transaction_Status, Cabin_Nr, @Sales_date,
      Cruise_Nr, Outlet_Nr, Stock_Code, (-1) * NetSalesPrice, (-1) * GrossSalesPrice, (-1) * Gratuity,
      (-1) * Discount, IsTaxApplicable, TaxType, (-1) * TaxAmount, (-1) * Amount_due, IsSalesDeducted_FromStock,
      Settlement_type, Payment_Type, IsSalePartiallyClosed, NewServerID, (-1) * Extra_Gratuities,
      isSelected, AIAccount_Nr, (-1) * AllInclusiveDiscount, IsAllInclusive, 1
      From Sales_Master Where Sales_Master.Transaction_Nr = 507627


-- On error return False
IF @@Error <> 0
      BEGIN
            ROLLBACK TRANSACTION
            Return 0
      END

-- Select Transaction_Nr of inserted record
Select @intNewTrnNr = Max(Transaction_Nr) From Sales_Master

-- On error return False
IF @@Error <> 0
      BEGIN
            ROLLBACK TRANSACTION
            Return 0
      END

-- Insert into Sales Details
DECLARE  @ShipNr As varchar(15)
DECLARE  @Batch As smallint
DECLARE  @PLU_ID As Int
DECLARE  @SortID As smallint
DECLARE  @Sales_Qty As smallint
DECLARE  @Unit_Price As Numeric(15,2)
DECLARE  @PLU_SpecifierID As Int
DECLARE  @PLU_SpecifierSurcharge As Numeric (15,2)
DECLARE  @TaxPercent As Numeric (15,2)
DECLARE  @Discount As Numeric (15,2)

DECLARE SALES_CURSOR CURSOR FOR
      SELECT ShipNr, Batch, PLU_ID, SortID, Sales_Qty, Unit_Price, PLU_SpecifierID, PLU_SpecifierSurcharge, TaxPercent, Discount From Sales_Details Where Transaction_Nr = @intTransactionNr

OPEN SALES_CURSOR
      FETCH NEXT FROM SALES_CURSOR INTO  @ShipNr,  @Batch,  @PLU_ID,  @SortID,  @Sales_Qty,  @Unit_Price,  @PLU_SpecifierID,  @PLU_SpecifierSurcharge,  @TaxPercent,  @Discount

      WHILE @@fetch_status=0
      
          BEGIN
            INSERT INTO Sales_Details Values(@ShipNr, @intNewTrnNr, @Batch,  @PLU_ID,  @SortID,  (-1) * @Sales_Qty,  @Unit_Price,  @PLU_SpecifierID,  @PLU_SpecifierSurcharge,  @TaxPercent,  (-1) * @Discount)

              FETCH NEXT FROM SALES_CURSOR INTO @ShipNr,  @Batch,  @PLU_ID,  @SortID,  @Sales_Qty,  @Unit_Price,  @PLU_SpecifierID,  @PLU_SpecifierSurcharge,  @TaxPercent,  @Discount
          END

CLOSE SALES_CURSOR

DEALLOCATE SALES_CURSOR

-- On error return False
IF @@Error <> 0
      BEGIN
            ROLLBACK TRANSACTION
            Return 0
      END
Else
      Begin

            COMMIT TRANSACTION

            RETURN 1
      End
GO
[+][-]04/18/06 05:40 AM, ID: 16477226Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/18/06 05:40 AM, ID: 16477230Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/18/06 05:51 AM, ID: 16477306Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Microsoft Visual Basic.Net
Tags: return, procedure, value, stored, from
Sign Up Now!
Solution Provided By: cubixSoftware
Participating Experts: 3
Solution Grade: A
 
 
Loading Advertisement...
20091021-EE-VQP-81