locked
when i enter a single character in textbox , that needs to find similar names RRS feed

  • Question

  • VB6.0 and SQL 2000

    Hai, i would like to ask about SQL statements, i'm using VB6.0 and my systems if more on searching record, so the SQL statements is very important to search a record, so back to the question, i do this to search the "company name"

    when i enter p in textbox , the starting names of p is want to add in listview to show no of names started in p.

    Private Sub txttitle_Change()
    inputname = UCase(txttitle.Text)
    Set rs = New ADODB.Recordset
    Set rs = Nothing
    rs.Open "select * from items where title like '*" & inputname & "' ", cn.ConnectionString, adOpenDynamic, adLockOptimistic
    Set rs1 = New ADODB.Recordset
    Set rs1 = Nothing
    rs1.Open "select count(*) from items where title like '*" & inputname & "' ", cn.ConnectionString, adOpenDynamic, adLockOptimistic

    If Not rs1(0) = 0 Then
    lv2.Visible = True
        While Not rs.EOF
            Set itmX = lv1.ListItems.Add(, , "" & Trim(rs(0)))
            rs.MoveNext
        Wend
    End If
    rs.Close
    End Sub

    For ex:

    if i entered = P

    "P" is stored as inputname

    i need answer likethis,

    program in c

    procedure

    process of design

    and so on...

    if i entered = "D" means

    Design of machanics

    design of object

    pls help.......


    Nithiyanantham

    Tuesday, January 8, 2013 7:59 AM

Answers

  • Hi,
    change youe SQL to this :

    rs.Open "select * from items where title like '" & inputname & "%' ", cn.ConnectionString, 

    Please take care about the single quote that i have placed in :

    title like '" & inputname & "%' ",

    Hope this helps.


    One good question is equivalent to ten best answers.

    • Marked as answer by Nithiyanantham Wednesday, January 9, 2013 7:51 AM
    Tuesday, January 8, 2013 10:37 AM