DataTable Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Uri Dimant

    #1

    DataTable Question

    VS2005

    I'm a little bit counfused about the below scenario

    An user will be able to write within a combobox control for certain name
    ,like
    he types 'A' and all names begin in 'A' will be filled in combo and he may
    want to continue typing as
    AD' and all names that begin in 'AD' will be filled respectively


    Now it is my question. How to get it fileed more efiicient? I mean each time
    the user types a literal i call the function that filter a table in sql
    server and returns the data to the combobox OR fill the data table/data set/
    array with all data (about 140.000 rows) by default and then loop throu a
    datatable and filter there


    Any ideas, thanks







  • Ken Tucker [MVP]

    #2
    Re: DataTable Question

    Hi,

    Take a look at the combobox now has some autocomplete features.

    http://msdn2.microsoft.com/en-us/lib...tomsource.aspx

    Imports System.Data.Sql Client

    Public Class Form1

    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) Handles MyBase.Load
    Dim strConn As String
    Dim da As SqlDataAdapter
    Dim conn As SqlConnection
    Dim ds As New DataSet

    strConn = "Server = .;Database = NorthWind; Integrated Security =
    SSPI;"
    conn = New SqlConnection(s trConn)

    da = New SqlDataAdapter( "Select * from Products", conn)

    da.Fill(ds, "Products")

    Dim ac As New AutoCompleteStr ingCollection
    For Each dr As DataRow In ds.Tables("Prod ucts").Rows
    ac.Add(dr.Item( "ProductName"). ToString)
    ComboBox1.Items .Add(dr.Item("P roductName").To String)
    Next


    ComboBox1.AutoC ompleteMode = AutoCompleteMod e.Append
    ComboBox1.AutoC ompleteSource = AutoCompleteSou rce.CustomSourc e
    ComboBox1.AutoC ompleteCustomSo urce = ac
    End Sub
    End Class


    Ken
    --------------------
    "Uri Dimant" <urid@iscar.co. il> wrote in message
    news:OKZ58YuiGH A.1276@TK2MSFTN GP03.phx.gbl...[color=blue]
    > VS2005
    >
    > I'm a little bit counfused about the below scenario
    >
    > An user will be able to write within a combobox control for certain name
    > ,like
    > he types 'A' and all names begin in 'A' will be filled in combo and he may
    > want to continue typing as
    > AD' and all names that begin in 'AD' will be filled respectively
    >
    >
    > Now it is my question. How to get it fileed more efiicient? I mean each
    > time the user types a literal i call the function that filter a table in
    > sql server and returns the data to the combobox OR fill the data
    > table/data set/ array with all data (about 140.000 rows) by default and
    > then loop throu a datatable and filter there
    >
    >
    > Any ideas, thanks
    >
    >
    >
    >
    >
    >
    >[/color]


    Comment

    Working...