I have vb.net application with MS access database.
I use following code to autocomplete textbox from database.
the problem is that, although its working but more frequently it gives an error "AccessViolationException was unhandled----Attempted to read or write protected memory. This is often an indication that other memory is corrupt." & the application is stoped working.
So what shuld i do?
Private Sub PatientNametxt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PatientNametxt.TextChanged
Dim con As New OleDbConnection
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Satyam\Documents\Pathology.accdb"
con.Open()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter("SELECT PatientName FROM Accessonbook", con)
da.Fill(dt)
Dim r As DataRow
PatientNametxt.AutoCompleteCustomSource.Clear()
For Each r In dt.Rows
PatientNametxt.AutoCompleteCustomSource.Add(r.Item(0).ToString)
Next
con.Close()
End Sub