locked
System.IndexOutOfRangeException RRS feed

  • Question

  • User20067001 posted
    Hello, I have the following code where all the used variable are declared to their respective types: insertSql = "SELECT Max([Customer ID]) AS CustID FROM [Registration Info]" objCommand = New OleDbCommand(insertSql, objConn) objConn.Open() objDR = objCommand.ExecuteReader() While objDR.Read() CustID=objDR("Cust ID") '********** (1.) End While I am getting an error on (1.). its says "System.IndexOutOfRangeException: Cust ID" why is this happening? Can comeone help me whith this problem? Thanks, ~s
    Wednesday, August 13, 2003 6:10 AM

All replies

  • User502787105 posted
    If the code enters the while loop then tere are values within objDR so why not add a watch to this and check the value of objDr(0) and then objDR(1) Hope that helps Cheers Gregor Suttie
    Wednesday, August 13, 2003 10:06 AM
  • User865851310 posted
    I would say it is happening because there is no field in the result called "Cust ID", though there is one called "CustID"
    Wednesday, August 13, 2003 10:59 AM
  • User20067001 posted
    Yes i know thats a silly mistake on my part. very silly... i wish i could delete this post. :) thanks very much. now i am doing it like objDR(0) Regards.
    Thursday, August 14, 2003 5:51 AM