Adodc1.RecordSource = "select Instore.ProId as 产品编号,ProName as 产品名称,Quantity as 数量,Hand as 经手人,InstoreCode as 票号,Instore.Indate as 日期 From Instore Join  Product on dbo.Instore.ProId=dbo.Product.ProId where Instore.Indate between '" + Str(DTP1.Value) + "' and '" + Str(DTP2.Value) + "' and  " & a & "  Like  '" + Text1.Text + "+ % +" '提示LIKE 附近有语法错误?

解决方案 »

  1.   

    Debug.Print Adodc1.RecordSource 
    看看出来的结果是什么
      

  2.   

    Dim strSql As StringstrSql="select Instore.ProId as 产品编号,ProName as 产品名称,Quantity as 数量,Hand as 经手人,InstoreCode as 票号,Instore.Indate as 日期 From Instore Join  Product on dbo.Instore.ProId=dbo.Product.ProId where Instore.Indate between '" + Str(DTP1.Value) + "' and '" + Str(DTP2.Value) + "' and  " & a & "  Like  '" + Text1.Text + "+ % +" 'Debug.Print strSql   '<------------------------------看看立即窗口出来的是什么,这样容易看出什么地方不对Adodc1.RecordSource=strSql
      

  3.   

    faysky2()  还是
    编译错误
    无效或不合格的引用全部的代码:
       If Check1.Value = 1 And Check2.Value = 1 Then
         Dim sql As String
         sql = "select Instore.ProId as 产品编号,ProName as 产品名称,Quantity as 数量,Hand as 经手人,InstoreCode as 票号,Instore.Indate as 日期 From Instore Join  Product on dbo.Instore.ProId=dbo.Product.ProId where Instore.Indate between '" + Str(DTP1.Value) + "' and '" + Str(DTP2.Value) + "' and  " & a & "  Like  '" + Text1.Text + "+ % +" '"
          Debug.Print .RecordSource = sql
          Adodc1.Refresh
          Set DataGrid1.DataSource = Adodc1
           End If
      

  4.   

    Like  '" + Text1.Text + "+ % +" '"
    =======================================
     Like  '" + Text1.Text + " %'"在Debug.Print .RecordSource = sql后面加一句Exit Sub ,运行后,按Ctrl+G弹出立即窗口 ,看看它里面显示的是什么内容......
    Debug.Print .RecordSource = sql
    Exit Sub
    Adodc1.Refresh
    ......
      

  5.   

    上面debug.print 后面的参数写错了,应该是这样:Debug.Print sql
      

  6.   

    select Instore.ProId as 产品编号,ProName as 产品名称,Quantity as 数量,Hand as 经手人,InstoreCode as 票号,Instore.Indate as 日期 From Instore Join  Product on dbo.Instore.ProId=dbo.Product.ProId where Instore.Indate between '2006-02-26' and '2006-03-08' and    Like  ' % 
      

  7.   

    faysky2() 大哥就是高,我知道哪错了,a作用域的问题。
      

  8.   

    这回很容易就看出 like 前后都有错误 ,like 前面应该有一个列名的,也就是 变量 a 所指定的值,上面语句说明变量 a 没有被赋值,另外,like后面的语句也有问题,缺少了值和一个单引号