Angie,
Seems strange to pass an array of Parameters rather than just a ParameterCollection, but if that's what is being passed, then you could try something like this (untested code):
public int ExecuteScalar(string storedProcedureName, System.Data.SqlClient.SqlParameter[] parameters)
{
SqlCommand sc = new SqlCommand(storedProcedureName, MyConnection);
sc.CommandType = CommandType.StoredProcedure;
for (int i=0; i < parameters.length; i++)
{
sc.Parameters.Add(parameters[i]);
}
return (int)sc.ExecuteScaler();
~~Bonnie
>Hello everyone,
>
>I have been asked to implement the following signature :-
>
>
>public int ExecuteScalar(string storedProcedureName, System.Data.SqlClient.SqlParameter[] parameters)
>{
>
>}
>
>
>I presume that the SqlParameter array must be populated in the calling code. The task is to create five records in a SQL database with four columns. Could anyone give me an example of how to create the calling code that builds up the SqlParameter array parameter?
>
>This is an example of the sproc,
>
>
>dbo.InsertEmployee 'HARRISON', 'ANGIE', 'PROGRAMMER', 'IT'
>
>
>Assuming that I get the array passed into the ExecuteScalar method, how do you you call the SQLCommand so that the array is used?
>
>I know I am asking a lot but I have looked through the help all day and I cannot find anything that explains how to do this?
>
>Thank you so much!
>
>Angie.