StrataFrame Forum

Parameters collection for FillByStoredProcedure

http://forum.strataframe.net/Topic15966.aspx

By Bill Cunnien - 4/28/2008

How do I pass multiple parameters to the FillByStoredProcedure method?
By Trent L. Taylor - 4/28/2008

It is a ParamArray so you can just pass as many parms as you want or create an Object array....whichever works best for you:

MyBo.FillByStoredProcedure(Parm1, Parm2, Parm3)

or

MyBo.FillByStoredProcedure(New Object() {Parm1, Parm2, Parm3))
By Bill Cunnien - 4/28/2008

One of the data retrieval methods is MicroFour.StrataFrame.Business.BusinessLayer.FillByStoredProcedure(string, params System.Data.Common.DbParameter[]).  How do I pass a parameters collection?  Sorry, if I am not making myself clear.  Here is the code offending code in my BO:

public void FillByOrderIndex(int pPLType, int pOrderIndex)
{
     FillByStoredProcedure(
"spx_GetOrderItemList", pPLType, pOrderIndex);
}

By Trent L. Taylor - 4/28/2008

You have to supply a DbParameter.  If you are using SQL Server, then it would look something like this:

Me.FillByStoredProcedure("MyStoredSproc", New SqlParameter("@parm1", MyValue), New SqlParameter("@parm2", MySecondValue))
By Bill Cunnien - 4/28/2008

I did try this once:

SqlParameter mPLType = new SqlParameter("@pltype", pPLType);
SqlParameter mOrderIndex = new SqlParameter("@orderindex", pOrderIndex);
FillByStoredProcedure(
"spx_GetOrderItemList", mPLType, mOrderIndex);

It did not work...well, I didn't think it did.  It's a good thing to set the DataSourceKey on the BO, too.  BigGrin  It tends to misbehave when that is missing.  Once I put that back in, then both your code and my code works just fine.  Sorry for the oversight.  Blush

Thanks for helping!
Bill

By Trent L. Taylor - 4/28/2008

No problem...glad you got it going Smile