Results 1 to 5 of 5

Thread: [RESOLVED] How to add autocomplete search to textbox from database field?

Threaded View

  1. #1

    Thread Starter
    Lively Member HOTFIX's Avatar
    Join Date
    Sep 2008
    Posts
    91

    Resolved [RESOLVED] How to add autocomplete search to textbox from database field?

    Hi…

    I want to add autocomplete search feature to my application So when I type the first characters of the search key in the textbox, a drop list appear of suggested data from required field and the results list became lass as the entered characters match the search key “same idea of Google search toolbar”

    The application created using: VB2008 & MS Access .mdb
    Table name: store
    Table field name for search: Item Part Number

    This is my form search codes
    Code:
    Imports System.Data
    Imports System.Data.OleDb
    
    
    Public Class Form2
        Dim frm As New Form1
        Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source =" & Application.StartupPath & "\data.mdb"
        Dim Conn As New OleDbConnection(ConStr)
        Dim DataSet1 As New DataSet
        Dim SQLstr As String
        Dim m As String
    
    
        Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
    
            DataSet1 = New DataSet
    
            Static m As Integer = 0
            If tbSearch.Text = Trim("") Then Exit Sub
            ExactSearch()
            Conn.Open()
            Dim DataAdapter1 As New OleDbDataAdapter(SQLstr, Conn)
            DataAdapter1.Fill(DataSet1, "store")
    
            Conn.Close()
            tbSearchResulItemPartNumber.DataBindings.Clear()
            tbSearchResultItemDeascriptions.DataBindings.Clear()
            tbSearchResultItemLocation.DataBindings.Clear()
    
            tbSearchResulItemPartNumber.DataBindings.Add("Text", DataSet1, "store.Item Part Number")
            tbSearchResultItemDeascriptions.DataBindings.Add("Text", DataSet1, "store.Item Descriptions")
            tbSearchResultItemLocation.DataBindings.Add("Text", DataSet1, "store.Item Location")
    
            DataGridView1.DataSource = DataSet1
            DataGridView1.DataMember = "store"
            If Me.BindingContext(DataSet1, "store").Count = 0 Then
                MsgBox("No Result??!! ")
                Form1.Show()
                Me.Close()
            End If
    
            Exit Sub
    
        End Sub
    
        Public Sub ExactSearch()
            SQLstr = "SELECT * FROM store WHERE [Item Part Number ]= '" & tbSearch.Text & "'"
        End Sub
    
        
        Private Sub btnBACK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBACK.Click
            Me.Close()
            Form1.Show()
        End Sub
    
       
    End Class

    Kindly any suggested codes for adding autocomplete search...

    Regards…
    Last edited by HOTFIX; Nov 6th, 2008 at 10:41 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width