Need Help for Search

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • driff
    New Member
    • Jan 2008
    • 1

    Need Help for Search

    im having problem, with my searchform theres always an error,

    [CODE=vb]If cmbcourse.Text = "" Or txtfind = "" Then
    Adodc1.Recordse t.Filter = ""
    Adodc1.Refresh
    Exit Sub
    End If
    Adodc1.Recordse t.Filter = cmbcourse & " LIKE '*" & txtfind & "*'" this parts always bring error
    End Sub[/CODE]
    Last edited by Killer42; Jan 21 '08, 08:17 AM. Reason: Added CODE=vb tag
  • creative1
    Contributor
    • Sep 2007
    • 274

    #2
    try this

    Adodc1.Recordse t.Filter = cmbcourse & " LIKE '" & txtfind & "%'"

    instead of this

    Comment

    • daniel aristidou
      Contributor
      • Aug 2007
      • 494

      #3
      Originally posted by creative1
      try this

      Adodc1.Recordse t.Filter = cmbcourse & " LIKE '" & txtfind & "%'"

      instead of this
      I experienced similar problems and kinda gave up......
      What does % do?

      Comment

      • lotus18
        Contributor
        • Nov 2007
        • 865

        #4
        Originally posted by creative1
        try this
        [code=vb]
        Adodc1.Recordse t.Filter = cmbcourse & " LIKE '" & txtfind & "%'"
        [/code]
        instead of this

        Hi Daniel

        % is a wildcard character in string comparison (sql). You can also try this code

        [code=vb]
        Adodc1.Recordse t.Filter = cmbcourse & " LIKE '%" & txtfind & "%'"
        [/code]


        Rey Sean
        Last edited by lotus18; Jan 21 '08, 03:29 AM. Reason: code tag added

        Comment

        • daniel aristidou
          Contributor
          • Aug 2007
          • 494

          #5
          Originally posted by lotus18
          Hi Daniel

          % is a wildcard character in string comparison (sql). You can also try this code

          [code=vb]
          Adodc1.Recordse t.Filter = cmbcourse & " LIKE '%" & txtfind & "%'"
          [/code]


          Rey Sean
          My problem is that im searching the primary key. which is in the format of int32... i convert my string in the seach textbox but still get an error message invalid comparison (or something like that) System.string & system.int32

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            So, either cmbcourse or txtfind is returning an integer, from the sound of it.

            Comment

            • daniel aristidou
              Contributor
              • Aug 2007
              • 494

              #7
              Originally posted by Killer42
              So, either cmbcourse or txtfind is returning an integer, from the sound of it.
              Thats what i dont get...... the dat column is in the form of int32 and
              im converting my textbox string in to int32 and im still getting the same result

              Comment

              • debasisdas
                Recognized Expert Expert
                • Dec 2006
                • 8119

                #8
                If searching on the primary key field why to use LIKE search .

                Comment

                • daniel aristidou
                  Contributor
                  • Aug 2007
                  • 494

                  #9
                  Well i was using like because of column searched changes with the change of selection of a combo box.......il try using = i supose...but i means putting in a case.........or if

                  Comment

                  • debasisdas
                    Recognized Expert Expert
                    • Dec 2006
                    • 8119

                    #10
                    Originally posted by daniel aristidou
                    My problem is that im searching the primary key. which is in the format of int32...
                    since searching on PK of int type .there is no use of LIKE at all.

                    Comment

                    • Killer42
                      Recognized Expert Expert
                      • Oct 2006
                      • 8429

                      #11
                      I think we need more detail here on cmbcourse, txtfind, the database fields being identified in cmbcourse, and basically, what the heck you are trying to put into Filter, which is a string.

                      Comment

                      • daniel aristidou
                        Contributor
                        • Aug 2007
                        • 494

                        #12
                        Fixed it ............tha nks for the tips

                        Comment

                        • Killer42
                          Recognized Expert Expert
                          • Oct 2006
                          • 8429

                          #13
                          Originally posted by daniel aristidou
                          Fixed it ............tha nks for the tips
                          Cool. Glad you got it sorted.

                          Comment

                          Working...