I have a simple stored procedure that takes one parameter and has two output parameters. I want to call this stored procedure in Access VB and read the 2 output parameters to use them in the VB code. How do I do this?
ALTER PROCEDURE [dbo].[spTest]
@Input1 nvarchar(100),
@Output1 int OUTPUT,
@Output2 varchar(100) OUTPUT
AS
BEGIN
SET @Output1 = 30
SET @Output2 = 'OK'
RETURN 0
END
This is the closest thing to what I'm looking for, but when I try to paste it into Access VBA it highlights a bunch of lines in red as if the syntax was way off.
Using connection As New System.Data.SqlClient.SqlConnection(connectionstrng) 'Error here
connection.Open() 'Error here
Using command As New System.Data.SqlClient.SqlCommand("sp_Custom_InsertxRef", connection) 'Error here
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("@DocumentID", SqlDbType.Int, 4, ParameterDirection.Input).Value = epdmParDoc.ID
command.Parameters.Add("@RevNr", SqlDbType.Int, 4, ParameterDirection.Input).Value = epdmParDoc.GetLocalVersionNo(parFolderId)
command.Parameters.Add("@xRefDocument", SqlDbType.Int, 4, ParameterDirection.Input).Value = targetReplaceDoc.ID
command.Parameters.Add("@xRefRevNr", SqlDbType.Int, 4, ParameterDirection.Input).Value = targetReplaceDoc.CurrentVersion
command.Parameters.Add("@xRefProjectId", SqlDbType.Int, 4, ParameterDirection.Input).Value = parFolderId
command.Parameters.Add("@RefCount", SqlDbType.Int, 4, ParameterDirection.Input).Value = count
'command.Parameters.Add("@xRef", OleDbType.Integer, 4, ParameterDirection.InputOutput).Value = -1
command.Parameters.Add("@xRef", SqlDbType.Int) 'Error here
command.Parameters("@xRef").Direction = ParameterDirection.Output
command.ExecuteReader() 'Error here
xRefId = command.Parameters("@xRef").Value
End Using 'Error here
connection.Close() 'Error here
End Using