I am trying to write program in vb6.0, in which i am using ms access database. i want to search in a table called "customer". the Field is called "Name". in the feild i have saved full name e.g Asmat Ullah Khan, Asmat Khan, Asmat Ullah. now what i want to do is search only Asmat and it should go through whole table and display all the names in listview i.e Asmat Ullah Khan, Asmat Ullah, Asmat Khan. how can i search to get this result.Thank you

This question has been asked and answered several times already. if you try to use the search bar on this forum, you find the answer to your question. you can also use GOOGLE to find answer to your question.

here are some links that could help you.

https://www.daniweb.com/software-development/visual-basic-4-5-6/threads/29709/search-code-in-a-database

https://www.daniweb.com/software-development/visual-basic-4-5-6/threads/334183/how-to-create-a-search-command-in-vb6

https://www.daniweb.com/software-development/visual-basic-4-5-6/threads/445719/how-to-search-database-and-display-matching-record-in-vb6-

i tried the links you send but my problem is still there let me tell little more what i want and what i am getting
there is table called "Customer" fiels called "CName"
now CName is Full name
eg
Asmat
Asmat Ullah
Asmat Ullah Khan
Asmat Khan
asmat
asad
ali

now when i load the code which is

Private Sub CmdCSearch_Click()
    If TxtCSearch.Text = "" Then
        Dim info As String
        If Option1.Value = True Then
            info = "Customer ID"
        Else
            info = "Customer Name"
        End If
        MsgBox "First Enter " & info & "."
        TxtCSearch.SetFocus
    Else
        '###############################################
        Dim rsCSearch As ADODB.Recordset
        Set rsCSearch = New ADODB.Recordset
        'rsCSearch.Open "Customer", gobjConn, adOpenDynamic, adLockPessimistic
        If Option1.Value = True Then
            rsCSearch.Filter = "ID='" & TxtCSearch.Text & "'"
        Else
            'rsCSearch.Filter = "CName='" & Trim(TxtCSearch.Text) & "%'"
            'SQL = "Select * FROM Customer WHERE CName like '" & Trim(TxtCSearch.Text) & "%'"
            rsCSearch.Open "SELECT * FROM Customer WHERE CName LIKE " & "'" & TxtCSearch.Text & "'", gobjConn, adOpenStatic, adLockOptimistic
        End If
        ListView2.ListItems.Clear
        Do Until rsCSearch.EOF = True
            Dim CustomerListObj As ListItem
            Set CustomerListObj = ListView2.ListItems.add(, , rsCSearch!ID)
            CustomerListObj.SubItems(1) = rsCSearch!CName
            rsCSearch.MoveNext
        Loop
    End If
End Sub

my DB connection is connected when my main page loads
and DB info is in modules
gobjConn is the connection name

now when i enter asmat in TxtCSearch (it is the textbox) i only get two results Asmat and asmat

i want to search like if i put "a" in textbox i should get all starting starting with "a"
if i put "as" then all result starting with "as" and if i put "asmat"
then i should get all asmat, asmat ullah, asmat ullah khan, asmat khan, and asmat
but i only get
asmat, Asmat 2 results

rsCSearch.Filter = "CName='" & Trim(TxtCSearch.Text) & "%'" 
'no result is shown
rsCSearch.Filter = "CName='" & Trim(TxtCSearch.Text) & "'"
only asmat, Asmat are shown
rsCSearch.Open "SELECT * FROM Customer WHERE CName LIKE " & "'" & TxtCSearch.Text & "%'", gobjConn, adOpenStatic, adLockOptimistic

got it working % was missing thanks for your time

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.