I’m trying to call the SQL statement below but get the following error:
System.Data.SqlClient.SqlException: Conversion failed when converting the varchar value ‘+@buildingIDs+’ to data type int.
@'SELECT id, startDateTime, endDateTime FROM tb_bookings WHERE buildingID IN ('+@buildingIDs+') AND startDateTime <= @fromDate';
buildingID is an int type column in the db. Will I need to pass the IDs as an array of ints?
Bravax’s way is a bit dangerous. I’d go with the following so you don’t get attacked with SQL Injections: