vb.net怎么查询某个表的所有字段是否包含某关键字?
这个语句哪里错误??DimDropAsStringDrop=DropDownList1.SelectedValueIfDrop="User_info"Thensql="s...
这个语句哪里错误?? Dim Drop As String Drop = DropDownList1.SelectedValue If Drop = "User_info" Then sql = "select * from '" + Drop + "' where field2&field3&field4&field5&field6&field7&field8 like '" + TextBox1.Text + "'" Dim sqlDS As DataSet sqlDS = db.Sel(sql) GridView1.DataSource = sqlDS GridView1.DataBind() 类的方法 Public Function Sel(ByVal sql As String) As DataSet Dim sqlCN As SqlConnection sqlCN = New SqlConnection("DATA SOURCE=PC-201112161229\SQLEXPRESS;UID=sa;PWD=731668914;DATABASE=RenLiZiYuan") Dim sqlCM As SqlCommand sqlCM = New SqlCommand(sql, sqlCN) Dim sqlDT As SqlDataAdapter sqlDT = New SqlDataAdapter sqlDT.SelectCommand = sqlCM Dim sqlDS As DataSet sqlDS = New DataSet sqlDT.Fill(sqlDS) sqlCN.Close() Return sqlDS
展开
1个回答
展开全部
like语句要加通配符,才能起到模糊匹配的作用 sql = "select * from '" + Drop + "' where field2&field3&field4&field5&field6&field7&field8 like '" + TextBox1.Text + "'" 改成 sql = "select * from '" + Drop + "' where field2&field3&field4&field5&field6&field7&field8 like "'%'" + TextBox1.Text + "'%'"
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询