VB查询语句问题

来源:百度知道 编辑:UC知道 时间:2024/07/02 17:23:17
Adodc1.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=RENSHI"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from 人事档案信息表 where( 人事档案信息表." & Combo1.Text & " like +'''+ Text1.Text + '''+'%')"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1

我的这些查询语句,为什么运行后只显示表头,没有内容呢,我用的是Adodc和DataGrid,请各位高手帮帮忙,很急,谢谢
Set DataGrid1.DataSource = Adodc1
Adodc1.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=RENSHI"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from 人事档案信息表 where( 人事档案信息表." & Combo1.Text & " like +'''& Text1.Text & '''+'%')"
Adodc1.Refresh

我这样弄还是不行啊,为什么呢

要把Set DataGrid1.DataSource = Adodc1 这句话放在查询语句的前面,

也就是说先帮定数据源,再查询

在字符串连接的时候最好不用+,用&
like后面应该有个空格