Hi all,
I need some help...i am writing a small harness application to test a component written by the dev team in my company. My app basically allows you to build a database command object through the ui - so specify a sql query, db connection and parameters, run this against the component being tested, and then display the results in the UI.
For the parameter collection, my idea was to use an arraylist to pick up the specified parameters (benefits are variable size and also can pick up any data type, which is necessary as parameters will be a range of types).
However, when i execute the code, I get back a custom error message from the component saying "Parameter count is incorrect". However, if i use a normal array it works - so there is something specific about ArrayLists that isn;t working.
So just as a quick example, say i build my arraylist like this:
Code:
ArrayList myArrayList = new ArrayList();
myArrayList.Insert(0, "Test1");
myArrayList.Insert(1, "Test2");
Then this is the code i am using to call the function in the component i'm testing, specifying my arraylist as a parameter (the function accepts a params object]:
Code:
command = new SqlCommand();
command.ConnectionTitle = connTitle;
command.CommandID = cmdId;
command.SqlCommandType = SqlCommandType.CommandFile;
command.AddParameters(myArrayList);
That when i execute the above code, it doesn't work. However, if i use an Array instead of an arraylist, it does work, so:
Code:
string[] myarray = new string[2];
myarray.SetValue("Test1",0);
myarray.SetValue("Test2",1);
That returns results as expected....
Hope it's clear what i'm trying to do. Can anyone help???
Thanks!
Crazy-Nun