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.ExecuteRead erToValida teLogClass (procName, paramList);
}
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.ExecuteRead
}
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-
Hope it helps !
Pls try like below-
rt string;
foreach (SqlParameter p in paramList)
{
rt = StagingDBCalls.ExecuteReaderToValidateLogClass(procName, p);
}
Hope it helps !
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Experts
ASKER
Thanks a lot
ASKER
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.
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.
Thank you.
ASKER
Thanks much All, I will take care of this in future posts.
Try this..
Open in new window