Limit on columns in SqlDataReader? RRS feed

  • Question

  • Hi all


    My application uses a datareader which runs off a stored procedure. I'm finding that when I try to access certain columns, I get an IndexOutOfRange exception.


    Whether I access the columns by column number or by name the result is the same: I can access the 59th column, but not the 60th, or any column beyond that.


    I can see these columns just fine when I simply run the stored procedure in SQL Server, I just can't access them in the DataReader.


    Is there a limit on the number of columns in the DataReader that isn't described in the documentation?





    Wednesday, February 13, 2008 6:38 PM


  • This is just bad design of your application relational model so see if you can move the columns to a UNION ALL View and run your stored procedure from the view and call it from .NET.  The other option is to create a global temp table that is the temp table with two pound ## sign and run your stored procedure from that temp table, here you could still run into scope issues.


    Wednesday, February 13, 2008 7:28 PM