当前位置: 代码迷 >> VB Dotnet >> VB数据库搜索 不全咋回事
  详细解决方案

VB数据库搜索 不全咋回事

热度:90   发布时间:2016-04-25 02:10:05.0
VB数据库搜索 不全怎么回事?
1-小剪刀
2-花剪刀
3-铁皮剪刀
4-钢筋剪刀


输入“剪刀”搜索不到
输入“?剪刀”出现  小剪刀 和花剪刀
输入“??剪刀”出现铁皮剪刀 和 钢筋剪刀

能不能输入“剪刀”4个剪刀一起出来




。。。。。
。。。。。
      BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
         NumButtons      =   3
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "输入“信息”,点击查询!"
            Key             =   "cx"
            ImageIndex      =   1
            Object.Width           =   900
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   4
            Object.Width           =   5000
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "退出"
            Key             =   "exit"
            ImageIndex      =   4
         EndProperty
      EndProperty
      BorderStyle     =   1
      Begin VB.Timer Timer1 
         Interval        =   1000
         Left            =   0
         Top             =   9360
      End
   End
 。。。。。。。。。。
。。。。。。。。。。
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
  Select Case Button.Key
    Case "cx"
      selectsql = ""
      If text1(0) <> "" Then
        If selectsql <> "" Then
          selectsql = "kdrq like +'" + text1(0) + "'+'%'and " & selectsql
        Else
          selectsql = "kdrq like +'" + text1(0) + "'+'%'"
        End If
      End If
      If text1(1) <> "" Then
        If selectsql <> "" Then
          selectsql = "ywf like+ '" + text1(1) + "'+'%'and " & selectsql
        Else
          selectsql = "ywf like + '" + text1(1) + "'+'%'"
        End If
      End If
      If text1(2) <> "" Then
        If selectsql <> "" Then
          selectsql = "jbr like+ '" + text1(2) + "'+'%'and " & selectsql
        Else
          selectsql = "jbr like+ '" + text1(2) + "'+'%'"
        End If
      End If
      If text1(3) <> "" Then
        If selectsql <> "" Then
          selectsql = "spmc like +'" + text1(3) + "'+'%'and " & selectsql                     ‘’这个就是商品名称
        Else
          selectsql = "spmc like + '" + text1(3) + "'+'%'"
        End If
      End If
      If text1(4) <> "" Then
        If selectsql <> "" Then
          selectsql = "ck like+ '" + text1(4) + "'+'%'and " & selectsql
        Else
          selectsql = "ck like +'" + text1(4) + "'+'%'"
        End If
      End If
      If selectsql <> "" Then
        Adodc1.RecordSource = "select * from tempxsph where " & selectsql
        Adodc1.Refresh
      Else
        Adodc1.RecordSource = "select * from tempxsph"
        Adodc1.Refresh
      End If
    Case "xgjj"
      Dim mybookmark
      myval = InputBox("请输入更改的“进价”", "输入")
      cnn.Execute ("update tempxsph set 进价=" & Val(myval) & " where 商品编号='" + DataGrid1.Columns(0) + "'")
      mybookmark = DataGrid1.Bookmark
   
      Adodc1.Refresh
      DataGrid1.Bookmark = mybookmark
    Case "plcl"
      myval = InputBox("请输入进价上调或下调的价格。上调如“+1”,下调如“-1”", "输入")
      On Error Resume Next
      If selectsql <> "" Then
        cnn.Execute ("update tempxsph set 进价=进价" & myval & " where " & selectsql)
      Else
        cnn.Execute ("update tempxsph set 进价=进价" & myval)
      End If
      Adodc1.Refresh
    Case "exit"
      Unload Me
  End Select
End Sub


------解决思路----------------------
        If selectsql <> "" Then
          selectsql = "spmc like '%" + text1(3) + "%' and " & selectsql
        Else
          selectsql = "spmc like '%" + text1(3) + "%'"
        End If
  相关解决方案