Dim StrFilter As String
StrFilter = ""
'判断编号不为空
If Len(Trim(Text1.Text)) > 0 Then
    StrFilter = "" & Trim(Combo1.Text) & " ='" & Trim(Text1.Text) & "'"
End If
Adodc1.RecordSource = "select * from tips where " & StrFilter
Adodc1.Refresh
DataGrid1.ReBind
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False总是出现from子句有问题请问这个是什么问题

解决方案 »

  1.   


    Dim StrFilter As String 
    StrFilter = "" 
    '判断编号不为空 
    If Len(Trim(Text1.Text)) > 0 Then 
        StrFilter = Trim(Combo1.Text) & " ='" & Trim(Text1.Text) & "'" 
    End If 
    Adodc1.RecordSource = "select * from tips where " & StrFilter 
    Adodc1.Refresh 
    DataGrid1.ReBind 
    DataGrid1.AllowAddNew = False 
    DataGrid1.AllowDelete = False 
    DataGrid1.AllowUpdate = False 
      

  2.   

    照上面改后,仍然有问题,就是from子句有问题,是什么引号有问题呀
      

  3.   

    print出  你的SQL语句给我看看
      

  4.   

    Dim StrFilter As String 
    StrFilter = "" 
    '判断编号不为空 
    If Len(Trim(Text1.Text)) > 0 Then 
        StrFilter = " where " & Trim(Combo1.Text) & " ='" & Trim(Text1.Text) & "'" 
    End If 
    Adodc1.RecordSource = "select * from tips " & StrFilter 
    Adodc1.Refresh 
    DataGrid1.ReBind 
    DataGrid1.AllowAddNew = False 
    DataGrid1.AllowDelete = False 
    DataGrid1.AllowUpdate = False 
      

  5.   

    Dim StrFilter As String 
    StrFilter = "" 
    '判断编号不为空 
    If Len(Trim(Text1.Text)) > 0 Then 
        StrFilter = " where " & Trim(Combo1.Text) & " ='" & Trim(Text1.Text) & "'" 
    End If 
    Adodc1.RecordSource = "select * from tips " & StrFilter 
    Adodc1.Refresh 
    DataGrid1.ReBind 
    DataGrid1.AllowAddNew = False 
    DataGrid1.AllowDelete = False 
    DataGrid1.AllowUpdate = False 
      

  6.   


    Dim StrFilter As String 
    StrFilter = "" 
    '判断编号不为空 
    If Len(Trim(Text1.Text)) > 0 Then 
        StrFilter = "" & Trim(Combo1.Text) & " ='" & Trim(Text1.Text) & "'" 
    End If 
    Adodc1.RecordSource = "select * from tips where 1=1" & StrFilter 
    Adodc1.Refresh 
    DataGrid1.ReBind 
    DataGrid1.AllowAddNew = False 
    DataGrid1.AllowDelete = False 
    DataGrid1.AllowUpdate = False 
      

  7.   


    Dim StrFilter As String 
    StrFilter = "" 
    '判断编号不为空 
    If Len(Trim(Text1.Text)) > 0 Then 
        StrFilter = "" & Trim(Combo1.Text) & " ='" & Trim(Text1.Text) & "'" 
    End If 
    Adodc1.RecordSource = "select * from tips where 1=1 " & StrFilter 
    Adodc1.Refresh 
    DataGrid1.ReBind 
    DataGrid1.AllowAddNew = False 
    DataGrid1.AllowDelete = False 
    DataGrid1.AllowUpdate = False 
      

  8.   

    是不是Textbox1的内容有可能出现空的情况,那么select语句就会出现为题了.
      

  9.   

    不是Textbox1的内容有可能出现空的情况,上面的我都实验过了总是出现from子句有问题
      

  10.   


    If Len(Trim(Text1.Text)) > 0 Then 
        StrFilter = "" & Trim(Combo1.Text()) & " ='" & Trim(Text1.Text()) & "'" 
    End If 
    Adodc1.RecordSource = "select * from tips where " & StrFilter Adodc1.Refresh 
    DataGrid1.ReBind 
    DataGrid1.AllowAddNew = False 
    DataGrid1.AllowDelete = False 
    DataGrid1.AllowUpdate = False 
    发现了,!!COMBO1.TEXT(),TEXT1.TEXT()
      

  11.   


    Dim StrFilter As String 
    StrFilter = "" 
    '判断编号不为空 'If Len(Trim(Text1.Text)) > 0 Then 
        StrFilter = "" & Trim(Combo1.Text()) & " ='" & Trim(Text1.Text()) & "'" 
    End If 
    Adodc1.RecordSource = "select * from tips where " & StrFilter Adodc1.Refresh 
    DataGrid1.ReBind 
    DataGrid1.AllowAddNew = False 
    DataGrid1.AllowDelete = False 
    DataGrid1.AllowUpdate = False 剪切都没剪切完,不知道今天怎么了??老出错!!
      

  12.   

    那字符怎么还是不对呀??郁闷
    Dim StrFilter As String 
    StrFilter = "" 
    '判断编号不为空 
    If Len(Trim(Text1.Text)) > 0 Then 
        StrFilter = "" & Trim(Combo1.Text()) & " ='" & Trim(Text1.Text()) & "'" 
    End If 
    Adodc1.RecordSource = "select * from tips where 1=1 " & StrFilter 
    Adodc1.Refresh 
    DataGrid1.ReBind 
    DataGrid1.AllowAddNew = False 
    DataGrid1.AllowDelete = False 
    DataGrid1.AllowUpdate = False 
      

  13.   


    Dim StrFilter As String 
    StrFilter = "" 
    '判断编号不为空 '
    If Len(Trim(Text1.Text)) > 0 Then 
        StrFilter = "" & Trim(Combo1.Text()) & " ='" & Trim(Text1.Text()) & "'" 
    End If 
    Adodc1.RecordSource = "select * from tips where 1=1 " & StrFilter 
    Adodc1.Refresh 
    DataGrid1.ReBind 
    DataGrid1.AllowAddNew = False 
    DataGrid1.AllowDelete = False 
    DataGrid1.AllowUpdate = False 原来呢,用错了,用了SQL,汗!!
    试试看对不对??
      

  14.   


    Dim StrFilter As String 
    StrFilter = "" 
    '判断编号不为空 'If Len(Trim(Text1.Text)) > 0 Then 
        StrFilter = "" & Trim(Combo1.Text()) & " ='" & Trim(Text1.Text()) & "'" 
    End If 
    Adodc1.RecordSource = "select * from tips where " & StrFilter Adodc1.Refresh 
    DataGrid1.ReBind 
    DataGrid1.AllowAddNew = False 
    DataGrid1.AllowDelete = False 
    DataGrid1.AllowUpdate = False 55555555555555
      

  15.   


    Dim StrFilter As String 
    StrFilter = "" 
    '判断编号不为空 'If Len(Trim(Text1.Text)) > 0 Then 
        StrFilter = "" & Trim(Combo1.Text()) & " ='" & Trim(Text1.Text()) & "'" 
    End If 
    Adodc1.RecordSource = "select * from tips where " & StrFilter Adodc1.Refresh 
    DataGrid1.ReBind 
    DataGrid1.AllowAddNew = False 
    DataGrid1.AllowDelete = False 
    DataGrid1.AllowUpdate = False 
    狂顶了!!!5555555