Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-10-27
3
Medium Priority
?
638 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 2000 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
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.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

722 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