I have written a stored procedure:
USE [database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [database table]
@StoreNum INT,
@CustomerID INT,
@r VARCHAR(100) OUTPUT
AS
BEGIN
Select @r = Notes FROM [Database table]
WHERE CustomerID = @CustomerID
AND StoreNumber = CAST(@StoreNum AS NVARCHAR(10))
END
When I run this stored procedure in SQL server management studio, @r returns the string I am expecting.
However with the following C# code below I get the error: "Cannot convert from int to string".
SqlParameter param4 = new SqlParameter("@StoreNum", storeaudit.StoreNumber);
SqlParameter param5 = new SqlParameter("@CustomerID", "9");
SqlParameter param7 = new SqlParameter("@r", "");
param5.SqlDbType = System.Data.SqlDbType.Int;
param7.Direction = System.Data.ParameterDirection.Output;
var NoteMan = db.Database.ExecuteSqlCommand("sp_GetNotesData @StoreNum, @CustomerID, @r", param4, param5, param7);
String managers = param7.Value.ToString();
System.Console.WriteLine(param7.Value);
Any help would be greatly appreciated, thanks
UPDATE - Added the output and sqltype to the parameter and now the string managers returns "".