I have a stored procedure with the signature
PROCEDURE [dbo].[spValidateID]
    @ScanCode       VARCHAR(50),
    @Name           VARCHAR(50) = NULL OUTPUT,
    @ScanTime       DATETIME = NULL OUTPUT,
    @ValidationCode INT = 0 OUTPUT
This is supposed to return a validationCode and also populate the name and scanTime variables. I need to give it scanCode value while calling.
in my C# code I am doing like this.
using (var context = new DBEntities())
{
    var pScanCode = new SqlParameter("ScanCode", scanCode);
    var opName = new SqlParameter("Name", name);
    var opScanTime = new SqlParameter("ScanTime", scanTime);
    var opValidationCode = new SqlParameter("ValidationCode", validationCode);
    var test = context.ExecuteStoreQuery<int>("spValidateID @ScanCode, @Name, @ScanTime, @ValidationCode", pScanCode, opName, opScanTime, opValidationCode);
}
but while running this I m getting error No mapping exists from object type System.RuntimeType to a known managed provider native type.
any idea??
You are missing ouput settings for your sqlparameters and @. Your code should look something like this:
SqlParameter pScanCode = new SqlParameter("@ScanCode", ScanCode);
SqlParameter opName = new SqlParameter("@Name", name);
opName.Direction = System.Data.ParameterDirection.Output;   //Important!
SqlParameter opScanTime = new SqlParameter("@ScanTime", scanTime);
opScanTime.Direction = System.Data.ParameterDirection.Output;   //Important!
SqlParameter opValidationCode = new SqlParameter("@ValidationCode ", validationCode);
opValidationCode.Direction = System.Data.ParameterDirection.Output;   //Important!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With