I want to define a complete SQL statement condition after where
through the linking implementation of string, because I am not sure how many conditions after where
there are.
for (int i = 0; i < listView2.Items.Count; i++)
{
if (!is_first)
{
para += "maccount" +" "+ "=" + listView2.Items[i].Text;
is_first = true;
}
else
{
para += " or " + "maccount"+"="+ listView2.Items[i].Text;
}
}
MessageBox.Show(para);
string sql3 = "select maccount,msum from pharmaceutical_stocks where @para";
SqlParameter[] parameters3 = new SqlParameter[]
{
new SqlParameter("@para",para)
};
DataTable dt = sqlcontent.dt(sql3, parameters3);
I want to find data in the database by the information saved in each item in listview2。
But I get this exception:
System.Data.SqlClient.SqlException: An expression of non-Boolean type is specified in the context in which the condition should be used (near '@para').