VB 查询数据库,SQL 语言=<>,都可以用,但是 like 查询不到结果……
Private Sub Command11_Click()Dim sql As String
Dim tiaojianChaXunRs As New ADODB.Recordset
If Trim(Combo6.Text) <> "" And Trim(Combo7.Text) <> "" Then
If Combo7.Text <> "like" Then
sql = "select * from " & Trim(Combo5.Text) & " where " & Trim(Combo6.Text) & " " & Trim(Combo7.Text) & " '" & Trim(Text7.Text) & "'"
Else
sql = "select * from " & Trim(Combo5.Text) & " where '" & Trim(Combo5.Text) & "'." & Trim(Combo6.Text) & " like '%" & Trim(Text7.Text) & "% '"
End If
End If
If tiaojianChaXunRs.State Then tiaojianChaXunRs.Close
tiaojianChaXunRs.Open sql, conn, adOpenDynamic, adLockOptimistic
Set MSHFlexGrid4.DataSource = tiaojianChaXunRs
combo5是表名,combo6是字段名,combo7下有= < > <> like ,除like外其他都可以查询到结果,不知道到底出错在哪??求大神解救