VB与SQL嵌套查询

来源:百度知道 编辑:UC知道 时间:2024/06/03 18:25:58
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\桌面\liyawei毕设程序\DataBase\Data.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from Book where '书名' = '%Text1.text%'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox "数据库没有符合要求的纪录!"
Exit Sub
End If
Set DataGrid1.DataSource = Adodc1
运行结果不报错,但也没有想要的结果,在数据库中有要查询的记录,但结果是:"数据库没有符合要求的纪录!"

select * from Book where '书名' = '%"+Text1.text+"%'
单引号里面的会被认为是查找内容,你的程序意思是查找%Text1.text%。但我觉得你的意思是要找Text1中填写的内容,并且是模糊查询