Link to home
Start Free TrialLog in
Avatar of mugsey
mugseyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

how to to use sqlparameter collection

Say if I have a parameter type of

             List<SqlParameter> reportParameters

How would I amend the code below so it works with the code below

You see I have

foreach (SqlParameter param in reportParameters)

Now I want to amend the code below so I can pass in a list of parameters or EVEN optional parameters
foreach (SqlParameter param in reportParameters)
 
        }

Open in new window

Avatar of jandromeda
jandromeda
Flag of Sri Lanka image

Can you explain the problem little bit in detail?
Avatar of mugsey

ASKER

HI Yes

I am writing reports using Reporting Services (RDLC) files.  I want to pass a sproc and an optional set of sql parameters to this

public static DataTable GetReportDataTable(string strSprocName, List<SqlParameter> reportParameters)
{

  loop through the sql parameters and execute the sproc to return the datatable
}

ASKER CERTIFIED SOLUTION
Avatar of ZachSmith
ZachSmith
Flag of United States of America 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
Use the foreach loop given by ZachSmith. It uses defensive programming.