Error with ODBC database RRS feed

  • Question

  • User1626849611 posted

    Hi, not to sure if ive posted this in the correct section! Trying to read rows from an odbc database into a List to be passed onto Ajax autocomplete but i keep getting the error "System.StackOverflowException" Make sure you do not have an infinite loop or infinite recursion.


    Heres my code:


        <WebMethod()> _
            <ScriptMethod()> _
        Public Function GetCompletionList() As String()
            Dim myConn As OdbcConnection
            Dim myCommand As OdbcCommand
            Dim SearchFilterCmd As String
            myConn = New OdbcConnection("Dsn=PFXtrain;uid=pfxuser;database=PFXtrain")
            SearchFilterCmd = "SELECT name FROM pfxuser.drmaster"
            myCommand = New OdbcCommand(SearchFilterCmd, myConn)
            Dim suggestions As New List(Of String)()
            myConn.ConnectionTimeout = 50000
                Dim dr As OdbcDataReader
                dr = myCommand.ExecuteReader 'Error occurs here
                While dr.Read
                End While
            Catch ex As Exception
                'do exception stuff
            End Try
            Return suggestions.ToArray
        End Function
    It may be something simple but i just can see it!
    Wednesday, June 22, 2011 4:01 AM


All replies

  • User-693248168 posted

    How many records does your table have? Hope they are not in millions? Try selecting few records instead of all rows.

    Wednesday, June 22, 2011 5:31 AM
  • User1626849611 posted

    Hi Lateef,


    There would be about 100 rows in total if i change the command string to "SELECT name FROM pfxuser.drmaster WHERE name LIKE 'Dub%'" there are about 4 corresponding rows but the same error still occurs?

    Wednesday, June 22, 2011 5:42 AM
  • User-693248168 posted

    Put a breakpoint on the return statement and see how many rows are getting returned.

    Wednesday, June 22, 2011 7:12 AM
  • User1626849611 posted

    None of the rows are being returned it crashes out at "dr = myCommand.ExecuteReader" it was working perfectly for about 30mins there and now ive closed and opened visual web developer its started crashing again.

    Wednesday, June 22, 2011 7:35 AM
  • User-693248168 posted

    I am not sure if this could be the reason, but you are not closing the datareader nor the connection after fetching the records.

    Use dr.Close() and connection.Close() after reading the values.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 22, 2011 7:46 AM
  • User1626849611 posted

    Problem Solved,


    Thanks Lateef Cool

    Wednesday, June 22, 2011 11:15 AM