Dear All,
sorry for my english, I'm newbie in .Net programming
I am using vb. net 2010 framework 4. I want to make the autocomplete textbox but get error message "AccessViolationException". provisions:
2 pieces that use autocomplete textbox, textbox each data retrieved from a database type (sql server) but different databases. the code that I know:
First code of textbox 1 :
-------------------------
Call OpenInventory()
CommandInv.Connection = ConInv
CommandInv.CommandType = CommandType.Text
CommandInv.CommandText = "SELECT ART_NAME FROM ARTIST"
ObjDtAdapterInv.SelectCommand = CommandInv
ObjDtAdapterInv.Fill(objDataSetInv, "Artist")
ObjDtAdapterInv.Dispose()
Dim col As New AutoCompleteStringCollection
Dim i As Integer
For i = 0 To objDataSetInv.Tables("Artist").Rows.Count - 1
col.Add(objDataSetInv.Tables("Artist").Rows(i)("ART_NAME").ToString())
Next
TBArtist.AutoCompleteSource = AutoCompleteSource.CustomSource
TBArtist.AutoCompleteCustomSource = col
TBArtist.AutoCompleteMode = AutoCompleteMode.Suggest
CommandInv.Dispose()
ObjDtAdapterInv.Dispose()
ConInv.Close()
secondary code of textbox 2:
----------------------------
Call OpenAuction()
CommandAuct.Connection = ConAuct
CommandAuct.CommandType = CommandType.Text
CommandAuct.CommandText = "SELECT cli_firstname FROM tclient WHERE cli_firstname LIKE '%" & TBOwner.Text & "%'"
ObjDtAdapterAuct.SelectCommand = CommandAuct
ObjDtAdapterAuct.Fill(objDataSetAuct, "Owner")
Dim ColOwner As New AutoCompleteStringCollection
Dim i As Integer
For i = 0 To objDataSetAuct.Tables("Owner").Rows.Count - 1
ColOwner.Add(objDataSetAuct.Tables("Owner").Rows(i)("cli_firstname").ToString())
Next
TBOwner.AutoCompleteSource = AutoCompleteSource.CustomSource
TBOwner.AutoCompleteCustomSource = ColOwner
TBOwner.AutoCompleteMode = AutoCompleteMode.Suggest
CommandAuct.Dispose()
ObjDtAdapterAuct.Dispose()
ConAuct.Close()
The above code is running normal if only one textbox is executed, if executed after the first textbox and then executes the second textbox then get the error message. Please help urgent :( thanks b4