WHERE IN (array of IDs)

后端 未结 9 1262
暖寄归人
暖寄归人 2020-11-28 11:16

I have webservice which is passed an array of ints. I\'d like to do the select statement as follows but keep getting errors. Do I need to change the array to a string?

9条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 11:43

    [WebMethod]

    public MiniEvent[] getAdminEvents(int buildingID, DateTime startDate)

    ...

    SqlParameter buildID= new SqlParameter("@buildingIDs", buildingIDs);

    Perhaps I'm being over detailed, but this method accepts a single int, not an array of ints. If you expect to pass in an array, you will need to update your method definition to have an int array. Once you get that array, you will need to convert the array to a string if you plan to use it in a SQL query.

提交回复
热议问题