Solved

expects parameter '@message', which was not supplied ... vb.net

Posted on 2014-10-27
3
603 Views
Last Modified: 2014-10-27
I am running:

SQL.RecordCount = cmdSP.ExecuteNonQuery

where it complains about @message output parameter:Procedure or function 'spAddOrder' expects parameter '@message', which was not supplied., but as shown on line 13 below, this parameter is included.

Question: Is my syntax at line 13 correct?

              With cmdSP
                    ' CUSTOMER PARAMETERS AND VALUES
                    .Parameters.Add("@CustomerID", SqlDbType.Int, 4).Value = intCustID

                    ' ORDER PARAMETERS
                    Dim x As String = cboOrder.SelectedValue.ToString
                    Dim SoftID As Integer = x
                    .Parameters.Add("@SoftwareID", SqlDbType.Int, 4).Value = SoftID

                    Dim Qty As Integer = txtQuantity.Text
                    .Parameters.Add("@Quantity", SqlDbType.Int, 4).Value = Qty

                    .Parameters.Add("@message", SqlDbType.VarChar, 100).Direction = ParameterDirection.ReturnValue

                End With

Open in new window

I have tested the following proc in SSMS and it works
CREATE PROCEDURE [dbo].[spAddOrder]
     @CustomerID int
	, @SoftwareID int 
	, @Quantity int 
	, @message VARCHAR(100) OUTPUT
As
BEGIN

SET NOCOUNT ON;

Declare @OrderID int
Declare @AddedOrderCount int
Declare @msg varchar(100)=''

   Insert Into tblOrders (CustomerID, OrderDate)
				       Values(@CustomerID,GETDATE())

  Set @OrderID = SCOPE_IDENTITY()

  Insert Into tblOrderDetails(OrderID, SoftwareID, Quantity)
			         Values(@OrderID, @SoftwareID, @Quantity) 

Set @AddedOrderCount = @@ROWCOUNT

Set @msg ='Orders added: ' + CAST(@AddedOrderCount AS NVARCHAR(10));

if @@Error>0 
     Set @msg = @msg + '; SQL Server error: ' + CAST(@@Error AS NVARCHAR(10))

Set @message = @msg

Return @@Error

END 

/*
Declare @msg varchar(100)
Declare @message varchar(100)
Exec @msg = spAddOrder 1,2,14, @message OUTPUT
Select @msg 
Select @message 
*/

Open in new window

And here is a look at vs2012 Server Explorer:
ProcOutput
0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 40407026
.Parameters.Add("@message", SqlDbType.VarChar, 100).Direction = ParameterDirection.ReturnValue
should be
.Parameters.Add("@message", SqlDbType.VarChar, 100).Direction = ParameterDirection.Output


Return value would be "select 1"
0
 
LVL 34

Author Closing Comment

by:Mike Eghtebas
ID: 40407031
Thank you.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40407035
re> Return value would be "select 1"

Where this should go? Not in vs, right?
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question