locked
data reader - System.IndexOutOfRangeException RRS feed

  • Question

  • User-307753031 posted
    I'm getting the following runtime error message: AuthCode Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IndexOutOfRangeException: AuthCode Source Error: Line 76: If Not orderReader("AuthCode").GetType() Is GetType(DBNull) Then Source File: G:\BegECom\WroxJokeShop\UserControls\OrderDetailsAdmin.ascx.vb Line: 76 Stack Trace: [IndexOutOfRangeException: AuthCode] System.Data.Common.FieldNameLookup.GetOrdinal(String fieldName) System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) System.Data.SqlClient.SqlDataReader.get_Item(String name) -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032 -------------------------------------------------------------------------------- My watch window info: Name: orderReader("AuthCode") Value: "Run-time exception thrown : System.IndexOutOfRangeException - AuthCode" Name: orderReader("Reference") Value: "Run-time exception thrown : System.IndexOutOfRangeException - Reference" All other fields from the table appear in the data reader as expected. TIA, Randy
    Thursday, November 11, 2004 3:10 PM

All replies

  • User-1518520062 posted
    Hi Randy, You will have to check your select statement. Somehow column names are not what you expected. Use FieldCount to check number of columns in datareader. Use GetName method to check real name of column with specified index in watch window.
    Thursday, November 11, 2004 4:41 PM
  • User-307753031 posted
    Got it - Short term fix - add column names to select statement. Long term fix - turn computer off at midnight<bg>. Thanx! Randy
    Friday, November 12, 2004 10:48 AM
  • User-1518520062 posted
    I like your long term fix, Randy!
    Friday, November 12, 2004 6:18 PM