ADO.NET - The Size property has an invalid size of 0

前端 未结 10 1046
小蘑菇
小蘑菇 2020-12-14 13:41

I\'m trying to get output value from DB via ADO.NET. There\'s a client code:

    using (var connection = new SqlConnection(ConnectionString))
    {
                


        
10条回答
  •  旧时难觅i
    2020-12-14 14:21

    Everyone's answer was about as clear as mud to me. Maybe this will help someone now that I found what worked.

    Need to add size to the parameter

            DynamicParameters Params = new DynamicParameters();
            Params.Add("@ProfileID", ProfileID);
            Params.Add("@CategoryName", CategoryName);
            Params.Add("@Added", dbType: DbType.String, direction: ParameterDirection.Output,size:10);
    
            db.Execute(sql, Params, commandType: CommandType.StoredProcedure, commandTimeout: 60);
    
            var Added = Params.Get("@Added");
    

提交回复
热议问题