Skip to content

Unable to convert string as output. #659

@maxiwang

Description

@maxiwang

We find out an issue from stored procedure with DynamicParameters.Get("@outstring"). it always error exception converting data type nvarchar(max) to int.

stored procedure code:

ALTER PROC [dbo].[usp_Test]
@RESULT INT OUT,
	@OUTSTRING NVARCHAR(MAX) OUT
AS 
	SET @RESULT=1
	SET @OUTSTRING = 'HELLO WORLD!!'

c# code:

var dparams = new DynamicParameters();
dparams.Add("@RESULT", DbType.Int32, direction: ParameterDirection.Output);
dparams.Add("@OUTSTRING", DbType.String, direction: ParameterDirection.Output);
int row = conn.Execute("usp_Test", dparams, commandType:CommandType.StoredProcedure);
result = new Result() { 
  RESULT = dparams.Get<int>("@RESULT"), 
  OUTSTRING = dparams.Get<string>("@OUTSTRING") // here
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions