I have the task to parameterize inline sql queries but ran into a bump using IN. I have had no problems until now. It seems the code wants to compare the data-type of memId to @idcheck.
Here is a snippet of code for example:
Request(“idcheck”) is a value passed from a form that represents checkbox values. The above sample works when this value is (ex. 70); but not when this value is (ex. 70,71)
“Conversion failed when converting the varchar value '70,71' to data type int.”
Anyone run into this to find a simple solution.
Here is a snippet of code for example:
Code:
'Delete tbl_members WHERE memId IN (" & Request("idcheck") & ")
Dim oCmd As SqlCommand
oCmd = New SqlCommand
oCmd.CommandType = Data.CommandType.Text
oCmd.Parameters.Add(New SqlParameter("@idcheck", Data.SqlDbType.Int, 4, Data.ParameterDirection.Input, False, 0, 0, Nothing, Data.DataRowVersion.Default, Request("idcheck")))
oCmd.CommandText = "Delete tbl_members WHERE memId IN (@idcheck)"
‘…
Request(“idcheck”) is a value passed from a form that represents checkbox values. The above sample works when this value is (ex. 70); but not when this value is (ex. 70,71)
“Conversion failed when converting the varchar value '70,71' to data type int.”
Anyone run into this to find a simple solution.