Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


how to display the result from a query in a combobox immediately

how to display the result from a query in a combobox immediately

how to display the result from a query in a combobox immediately

Hello people,

I have made following code,
I wonder how do I change the Handles to display the result from my query immediately?

see code below:

CODE --> VB.net

Private Sub Cbx_Year_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cbx_Year.SelectedIndexChanged

        Dim Combobox As ComboBox = CType(sender, ComboBox)
        If Cbx_Year.SelectedItem IsNot Nothing Then
            Dim CurrentVal = CType(Cbx_Year.SelectedItem, String)
            '  MsgBox(CurrentVal)
        End If

        Dim Year_List_HashTable As New List(Of Integer)
        Dim Years_list As List(Of Integer)
        Dim dt As New DataTable()
        Dim dv As New DataView(dt)
        Dim ConnectionString As String = "Data Source=ttdev\Teknotrans_dev;Initial Catalog=myDatabase;Integrated Security=True"
        Dim myconn As New SqlConnection(ConnectionString)
        Using da As New SqlDataAdapter("SELECT DISTINCT [t0].[bestdatum] AS [Bestdatum]FROM [OpusOrder] AS [t0]", myconn)
        End Using
        Dim Years_Table As DataTable = dv.ToTable(True, "Bestdatum") ' tabellen ur databasen samt kolumen med datan
        For Each customer As DataRow In Years_Table.Rows
            Dim Year_Item = (customer("Bestdatum").ToString)
            Dim Year_String As String = (Year_Item.Substring(0, Year_Item.Length - 15))
        Years_list = Year_List_HashTable.Distinct().ToList ' Ta bort dubletter
        For Each item In Years_list
        Cbx_Year.SelectedIndex = 0

    End Sub 

Could someone help me ?

Thank you in advance

RE: how to display the result from a query in a combobox immediately

I found this work but is this the best way to make it?

CODE --> VB.net

Private Sub Cbx_Year_TabIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Cbx_Year.TabIndexChanged 

RE: how to display the result from a query in a combobox immediately

I don't understand the issue. When are the query results being displayed now?

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close