3

I find the problem accidentally. In my ArcMap add-in, there is a search function which allows the user to search the geodb based on the value of a field. It works fine but today when I right click the title in the datagridview casually, the ArcMap crashed. After that I simulate the scenario several times, every time ArcMap crashes.

My code is listed bellow:

Sql = "SELECT ITEM_NO AS 'ITEM NO', ITEM_CATEGORY_NO AS 'ITEM CATEGORY NO', ARRIVAL_DATE AS 'ARRIVAL DATE' FROM testDB WHERE ITEM_NO = '" + item_No + "'"

Try
        adapter = New SqlDataAdapter(Sql, connObj)
        adapter.Fill(ds)
        connObj.Close()
        DataGridView1.DataSource = ds.Tables(0)
        Catch ex As Exception
           MsgBox(ex.ToString)
End Try

The result is:

enter image description here

Once I right click the part in the red frame, the map will crash.

Can anyone please tell me what's wrong with my code?

  • What contains the datagridview (e.g. DockableWindow, Form, etc)? I don't think its related to your issue, butif you didn't open your connection before your .Fill...you don't need the connObj.Close(). Fill will close the connection automatically (but if you did have it open, Fill will leave it open). – Jay Cummins Aug 7 '14 at 12:35
  • Hi Jay, thanks for the clarification. I am using a form. Does it mean there is no way to avoid the crash? – ppLily Aug 8 '14 at 0:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.