why is it sometimes i get an error? it doesn't highlight the error


CODE

Dim SqlQuery As String = "Select UserName from Login"
            Dim SqlAdapter As New MySqlDataAdapter
            Dim SqlCommand As New MySqlCommand
            Dim Ds As New DataSet
            Dim i As Integer
            With SqlCommand
                .CommandText = SqlQuery
                .Connection = sConnect
            End With

            With SqlAdapter
                .SelectCommand = SqlCommand
                .Fill(Ds, "My List")
            End With

            Dim col As New AutoCompleteStringCollection
            For i = 0 To Ds.Tables(0).Rows.Count - 1
                col.Add(Ds.Tables(0).Rows(i)("UserName").ToString())
            Next
            txt1.AutoCompleteSource = AutoCompleteSource.CustomSource
            txt1.AutoCompleteCustomSource = col
            txt1.AutoCompleteMode = AutoCompleteMode.Suggest
            sConnect.Close()
            SqlAdapter.Dispose()
            SqlCommand.Dispose()

ERROR

System.AccessViolationException was unhandled
  Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
  Source="System.Windows.Forms"
  StackTrace:
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at textboxAutoComplete.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Recommended Answers

All 3 Replies

Exactly on which line the error occurs?

it does not highlight the error

up

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.