Link to home
Start Free TrialLog in
Avatar of Afzaal Khan
Afzaal Khan

asked on

Need to pass stored proc parameters in list

Hi Experts,

I have to get value of all parameters in a parameter list but it is passing the last parameter value only, kindly help.


-------------------------------


    public static class SSEService
    {

        public static List<log> Validate()
        {
            string procName = "[Stored Proc name]";

            var paramList = new List<SqlParameter>();
            var prm = new SqlParameter();

            prm.ParameterName = "@Data1";
            prm.DbType = System.Data.DbType.Int32;
            prm.Value = "0";

            prm.ParameterName = "@Data2";
            prm.DbType = System.Data.DbType.Int32;
            prm.Value = "0";

            prm.ParameterName = "@Data3";
            prm.DbType = System.Data.DbType.Int32;
            prm.Value = "1";

            prm.ParameterName = "@Data4";
            prm.DbType = System.Data.DbType.Int32;
            prm.Value = "0";

            paramList.Add(prm);

         
            return StagingDBCalls.ExecuteReaderToValidateLogClass(procName, paramList);

        }
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Hi,
Try this..

YourCommandObject.Parameters.Add(paramList);

Open in new window

Avatar of Afzaal Khan
Afzaal Khan

ASKER

Thanks Pavan , Actually I need to put the parameters in loop so that it will pass in list , can you help me with syntax pls
Hi,
Pls try like below-

rt string;
foreach (SqlParameter p in paramList)
{

   rt = StagingDBCalls.ExecuteReaderToValidateLogClass(procName, p);

}

Open in new window


Hope it helps !
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Experts
Thanks a lot
Thanks SouthMod..I am new to here please let me know how can I select multiple answers as Solution, I just selected but seems still selected one only.
You can select one solution as Best Solution and one solution as Assisted Solution. Now i think you have to open the question again. :)

Please request for moderation. It is present after the comment section at the bottom of your question.
@South - Could you please reopen the question. Now my answer is not selected.

Thank you.
Thanks much All, I will take care of this in future posts.