I am trying to run this code
public long getTopicCountWithTag(String tag)
{
long count;
query = " SELECT count(*) FROM [DB_us2].[dbo].[discns] where tags like '%@tags%'";
try
{
com = new SqlCommand(query, con);
com.Parameters.AddWithValue("@tags", tag);
con.Open();
sdr = com.ExecuteReader();
sdr.Read();
count= sdr.GetInt32(0);
}
catch (Exception e)
{
count = -1;
throw e;
}
finally
{
con.Close();
}
return count;
}
his conclusion 0. Therefore, I am trying to find out what the problem is and run a sample request in the management studio, but the output is different from providing it 1. After trying to permute the combinations, I think the problem with this statement com.Parameters.AddWithValue("@tags", tag);may be possible is @tagsnot replaced in the request.
source
share