CS中like问题
我在CS中根据关键字查找内容,语句如下:
string strsql = "select * form Item where Name like '% '+@GuanJianZhi+ '% ' ";
//SqlCommand myCommand = new SqlCommand(strsql, conn);
SqlDataAdapter ad = new SqlDataAdapter(strsql, conn);
string GuanJianZhi = TextBox1.Text.ToString();
ad.SelectCommand.Parameters.Add(new SqlParameter( "@GuanJianZhi ", SqlDbType.VarChar, 50));
ad.SelectCommand.Parameters[ "@GuanJianZhi "].Value = GuanJianZhi;
运行时提示Form附近有错误,问题出在哪?是我我的like '% '+@GuanJianZhi+ '% ' "这句写错吗?
[解决办法]
string strsql = "select * from Item where Name like '%@GuanJianZhi% ' ";
5555555555,我今天怎么这么大意阿