how to add a new parameter to SqlParameter[ ] Collection?

后端 未结 5 957
深忆病人
深忆病人 2021-01-20 14:46

I want to use something similar like this:

using (DataSet ds = new DataSet())
{
    SqlParameter[] dbParams = new SqlParameter[]
    {                                


        
5条回答
  •  天命终不由人
    2021-01-20 15:17

    If you know the maximum number of items (instanses of SQLParameter type) then following approach is ideal. Else you can go with List approach, which is briefed by peers.

     var dbParams = new SqlParameter[2];
     dbParams.SetValue(new SqlParameter("@PromptID", promptID),0);
     dbParams.SetValue(new SqlParameter("@ScenarioID", scenarioID), scenarioID != 0 ? 1 : 0);
    

提交回复
热议问题