I am using MS acess database 2007 and visula studio 2008.
i am working on a windows application where i need to use the autocomplete functionality in text box and it should take values from the data base.
this is the code i am using up for it
Private Sub TFreightType_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TFreightType.TextChanged
Dim conn1 As OleDbConnection
Dim connection1 As String
Dim command1 As String
Dim cmd1 As OleDbCommand
command1 = ("select distinct (Freight_Type) from Sheet1 ")
connection1 = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\application spot pricing\Database31.accdb"
conn1 = New OleDbConnection(connection1)
Try
conn1.Open()
Catch ex1 As Exception
MsgBox("Can not open connection ! ")
End Try
Try
cmd1 = New OleDbCommand(command1, conn1)
Dim dr1 As OleDbDataReader = cmd1.ExecuteReader()
If dr1.HasRows = True Then
While dr1.Read()
namesCollection.Add(dr1("Freight_Type").ToString())
Debug.Print(dr1("Freight_Type"))
End While
Else
MessageBox.Show("Data not found")
End If
dr1.Close()
Debug.Print(namesCollection.Item(0))
TFreightType.AutoCompleteMode = AutoCompleteMode.Suggest
TFreightType.AutoCompleteSource = AutoCompleteSource.CustomSource
TFreightType.AutoCompleteCustomSource = namesCollection
Catch ex As Exception
MsgBox("problem with data")
End Try
in debugging mode it is showing that it is picking the distinct values but the auto complete functionality is not getting reflected in the front end .
can any one help me with this?
thanks
This post has been edited by modi123_1: 10 May 2011 - 06:57 AM
Reason for edit:: please use code tags

New Topic/Question
Reply



MultiQuote





|