数据库连接问题
使用的是vs内置数据库
想要实现匹配部分字符,查询到数据
发现使用数字或英文可以匹配
使用中文就查询不到数据
部分代码:
string sql = "select * from [dbo].[table1] where title like '%" + str + "%'";
SqlCommand MyCommand = new SqlCommand(sql, con);
SqlDataReader dr = MyCommand.ExecuteReader();
if (dr.Read())
{
dr.Close();
SqlDataAdapter sda = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
sda.Fill(ds);
GridView1.DataSource = ds;
this.GridView1.DataBind();
}
else
{
Label1.Text = "未找到结果";
dr.Close();
}
多谢各位老哥哥 嘤嘤嘤