Can somebody please provide an example of how to use the ExecuteReader calling a stored procedure with a parameter array?
Asked
Active
Viewed 2,195 times
1
-
"Parameter array"? Do you mean the Parameters collection on the [SqlCommand](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspx)? – Michael Todd May 31 '11 at 16:01
-
Not sure if that's what I'm asking. The overload calls it a ParamArray of parameterValues declared as Object. I'm trying the parameters collection of the SQLCommand right now but getting an exception. So it may not be that. – Ahd Jun 01 '11 at 21:37
-
And maybe I should specify that I'm trying to use the Enterprise Library ExecuteReader. – Ahd Jun 01 '11 at 21:38
-
and I think I just solved my own problem. I was searching for ExecuteReader examples but should search for IDataReader – Ahd Jun 01 '11 at 21:39
-
Actually, IDataReader is an interface used by (for example) SqlDataReader, the object returned when running ExecuteReader from SqlCommand. It's "higher" in the chain and, while it may provide some tools to access your data, you'd be better off using the SqlDataReader methods (i.e. ExecuteReader) if you're accessing your data via a SqlCommand. – Michael Todd Jun 01 '11 at 21:55
1 Answers
0
Here is a site with an example:
If you are looking to just loop through the array of parameters, this code will work:

IAmTimCorey
- 16,412
- 5
- 39
- 75
-
Thank you for the example. I realize now I was asking for the wrong thing but than you anyway. Your suggestions got me on the right track (should be searching for iDataReader and not ExecuteReader) – Ahd Jun 01 '11 at 21:40