“SqlParameterCollection only accepts non-null SqlParameter type objects, not String objects”

后端 未结 8 1923
暗喜
暗喜 2021-01-04 07:23

I keep getting the exception

The SqlParameterCollection only accepts non-null SqlParameter type objects, not String objects

, while execut

8条回答
  •  星月不相逢
    2021-01-04 07:48

    I ran into the same error when I was using

    cmd.Parameters.Add(pars)
    

    where pars was a an array of SqlParameter. The issue was that I was using the Add() function but I should've used AddRange() instead.

    cmd.Parameters.AddRange(pars)
    

提交回复
热议问题