I am retrieving values from listbox and formatting them in string as
if (lbRaisedByLogin.SelectedIndex != -1)
{
foreach (ListItem item in lbRaisedByLogin.Items)
{
if (item.Selected == true)
{
sb.AppendFormat("{0},", item.Value);
}
}
searchCase.raisedByLogin = sb.ToString().TrimEnd(Convert.ToChar(","));
sb.Length = 0;
}
I am passing these strings to store procedure as parameter (Datatype-- Varchar(Max))
in stored procedure I am comparing these values like
SELECT * FROM AUS_CID_Cases
WHERE
AddedBy IN ( @raisedByLogin )
Where @raisedByLogin is one of the parameter i passed. It has values like @raisedByLogin="4,2,1"
AddedBy has datatype bigint.
When I run code I get error as "Error converting data type varchar to bigint.".. I understand it is because AddedBy column has datatype bigint. I can not change that datatype.
However when i cast AddedBy like
SELECT * FROM AUS_CID_Cases
WHERE
CAST(AddedBy as VARCHAR) IN ( @raisedByLogin )
I dont get error, but nothing is selected i.e I dont get any result from select statement.
What can I do?