我要在VB里面实现查询功能,利用ADODC控件和DATAGRID来显示,数据库是ACCESS但是在制作查询功能的时候实现不了,大家看看我的步骤有没有错误。
    1。把DATASOURCE属性设为ADODC。
    2。写入下面的语句:
 Form8.Adodc1.RecordSource = "select * from BooksInfo where LendInfo.ReadersInfo is +'" + Text1.Text + "'"
Form8.Adodc1.Refresh 
    Form8.Show vbModal, Me
     其中Text1.Text为要查询的内容。
    我觉得没有问题了,但是还是查询不了,大家帮帮我啦。。55555

解决方案 »

  1.   

    把下面的SQL语句改成查询的应该就差不多了'工程->引用->Microsoft ActiveX Data Objects 2.X Library
    '工程->部件->MicroSoft DataGrid Control 6.0 '使用datagrid
    '莫依MM原创Option ExplicitPrivate Rs As New ADODB.Recordset
    Private Conn As New ADODB.ConnectionPrivate Sub Form_Load()
     Dim strConn As String
     
     ' 连接数据库的字符串
     ' 连接带密码的数据库,直接在连接字符串后面加上;Jet OLEDB:DataBase Password='您的密码'
     ' 连接Access97数据库需要使用Jet.OLEDB.3.5,Access2K和以上数据库使用Jet.OLEDB.4.0
     strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\test.mdb;Persist Security Info=False"
     
     ' 使用客户端数据游标
     Conn.CursorLocation = adUseClient
     ' 打开Access的连接
     Conn.Open strConn
     
     ' 如果RecordSet的状态不是关闭状态,则关闭Recordset
     If Rs.State <> adStateClosed Then Rs.Close
     
     ' Recordser打开表People
     Rs.Open "Select * from People", Conn, adOpenKeyset, adLockOptimistic
     
     ' 报告出 一共多少笔数据,测试是否存在数据
     ' MsgBox Rs.RecordCount
     
     ' 绑定进DataGrid
     Set DataGrid1.DataSource = Rs
     
    End Sub
      

  2.   

    Form8.Adodc1.RecordSource = "select * from BooksInfo where LendInfo.ReadersInfo is +'" + Text1.Text + "'"//好像你这SQL语句写的不对吧,你是从BooksInfo 里查询数据,那LendInfo.ReadersInfo 中的这个LendInfo个表从哪来的?!
    建议你把SQL语句输出来,把查询分析器中执行一下.
      

  3.   

    我把SQL语句改成
       Form8.Adodc1.RecordSource = "select * from LendInfo where LendInfo.ReadersInfo is +'" + Text1.Text + "'"
       还是不行
      

  4.   

    写成
    Form8.Adodc1.RecordSource = "select * from LendInfo where ReadersInfo ='" & Text1.Text & "'"
    试试~
      

  5.   

    Form8.Adodc1.RecordSource = "select * from LendInfo where LendInfo.ReadersInfo ='" & Text1.Text & "'"
      

  6.   

    SQL语句有问题LendInfo.ReadersInfo 中的LendInfo和表名BooksInfo不等。
     "select * from BooksInfo where LendInfo.ReadersInfo is +'" + Text1.Text + "'"
    应该改成
     "select * from BooksInfo where BooksInfo.ReadersInfo is +'" + Text1.Text + "'"
    或者
    "select * from BooksInfo LendInfo where LendInfo.ReadersInfo is +'" + Text1.Text + "'"
      

  7.   

    where 后面为什么是is?应该是=吧
    而且好像连接sql语句该用&而不是+吧?
    我初学,说错了大家别骂我
      

  8.   

    Form8.Adodc1.RecordSource = "select * from BooksInfo where LendInfo.ReadersInfo is +'" + Text1.Text + "'"
    上面的幾位老兄都說了,兩個問題:第一個問題:LENDINFO表是哪里來的?第二個問題:is是什麼東東?如果查等于的話應該用"="號