Solved

URGENT!  VB.NET -- Can't dynamically refresh TextBox AutoCompleteSource

Posted on 2013-01-17
2
802 Views
Last Modified: 2013-01-18
Hello everyone,

I am dynamically filling a TextBox's AutoCompleteSource from an Oracle Database.

I want to use a Button click event to initiate action.

I can't seem to get a new list each time the button is clicked.

Here is the code snippet:

        Dim List1 As New List(Of String)
        Dim strSQL As String = "SELECT DISTINCT Value1 from Table1 ORDER BY Value1"
        Try
            Using cnn As New OracleConnection("USER ID=User1;DATA SOURCE=Data1;PASSWORD=PASS1;PERSIST SECURITY INFO=true;")
                Using cmd As New OracleCommand(strSQL, cnn)
                    cnn.Open()
                    Using dr As OracleDataReader = cmd.ExecuteReader
                        While dr.Read()
                            List1.Add(dr("Value1").ToString())
                        End While
                    End Using

                    cnn.Close()
                End Using
            End Using
        Catch ex As Exception

        End Try
        Dim Array1() As String = List1.ToArray
        TextBox1.AutoCompleteMode = AutoCompleteMode.Suggest
        TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
        TextBox1.AutoCompleteCustomSource.AddRange(Array1)

Thanks everyone!
0
Comment
Question by:eq2006
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 38789612
You may want to add

 TextBox1.AutoCompleteCustomSource.Clear()

at the start.
0
 

Author Closing Comment

by:eq2006
ID: 38795371
Thanks, works great!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
asp.net figure out error 3 26
Installing .NET 3.5 on Windows Server 2012 1 63
VB.Net Data Class 1 23
Copying from a network share 3 26
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question