mfriedenthal Posted August 18, 2005 Posted August 18, 2005 I have a VB.net app that stores data on SQL. I added a new field called "Status" to one of the SQL tables, of type bit, and created stored procedures to retrieve and edit the new field. Everything works perfectly when the app is compiled in Debug mode. However, when it is compiled in Release mode I get the following error: System.IndexOutOfRangeException: Status The code is executed OnLoad: Try MyAppConnection.Open() MyAppSQLCommand.Connection = MyAppConnection drResults = MyAppSQLCommand.ExecuteReader While drResults.Read If drResults("Status") Then Status = "Active" Else Status = "Not Active" End If liIndex = New ListItem(drResults("Name").ToString() & " - " & Status, drResults("I_ID").ToString) ddlInspectors().Items.Add(liIndex) End While drResults.Close() Catch ex As Exception RecordError(ex.ToString) Finally... The stack looks like: System.IndexOutOfRangeException: Status at System.Data.Common.FieldNameLookup.GetOrdinal(String fieldName) at System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) at System.Data.SqlClient.SqlDataReader.get_Item(String name) at MyApp.Utilities.MyMethod() Can anyone suggest a solution, or at least, how to go about tracking down the source of the error? Thank you. Quote
*Experts* Nerseus Posted August 18, 2005 *Experts* Posted August 18, 2005 You can set a breakpoint at the top to step through and see which line has the problem. It's likely the following line, since you mentioned adding the Status column to the query: If drResults("Status") Then The error line "System.Data.Common.FieldNameLookup.GetOrdinal(String fieldName)" is saying that it's trying to find a column by name and can't find it. That means the code certainly thinks a column isn't there. I'd check that you really are getting back the Status column (run the query directly through whatever tool you use). -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
mfriedenthal Posted August 18, 2005 Author Posted August 18, 2005 Thanks, Nerseus. I found my problem. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.