Saturday, April 12, 2014

Send Multiple parameters from sql to c# e.g comma separated two column values

1) SQL :   SET @RESULT =(SELECT CONVERT(NVARCHAR, LeadId) + ',' + Name
FROM  Lead WHERE (Email = @email))

2) C# :

  var outParam = new SqlParameter("@Result", SqlDbType.NVarChar);
                    outParam.Direction = ParameterDirection.Output;
                    outParam.Size = 100;
                    //  cmd.Parameters["@Result"].Direction = ParameterDirection.Output;


                    cmd.Parameters.Add(outParam);
                    cmd.ExecuteNonQuery();
                    Result = cmd.Parameters["@Result"].Value.ToString();

No comments:

Post a Comment