I\'m using a SqlDataReader
and get this exception when trying to read a column...
System.IndexOutOfRangeException: record
In my case this error was because I was accidentally executing two select statements in my command text. I had two separate output results and the first output didn't contain the column name I was reading and hence the error.
That's because you have no field named "record", you aliased it to "CUSTOMER_NO" so change the code to:
lblWebMasterMessage.Text += "record " + reader["CUSTOMER_NO"].ToString() + "<br />";
That said, you can also use index instead of name so to read the second column:
lblWebMasterMessage.Text += "record " + reader[1] + "<br />";