"Invalid attempt to read when no data is present."

"Invalid attempt to read when no data is present."

Old forum URL: forums.lhotka.net/forums/t/1902.aspx


albruan posted on Tuesday, December 05, 2006

While attempting to fetch data from my db, I get an "Invalid attempt to read when no data is present." message and I can't find the reason for it.  I'm attempting to return data for three fields, all of which are designated as being int values in the db.  I have two values I'm passing into my sproc to locate the appropriate row(s) of data in the db.  If I directly execute the sproc with those same two values in SQL Server Management Studio, I get four rows of data back; however, I get a row count of 0 rows after executing the "using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader))" statement. 

This particular BO is 99.99% the same as another one that retrieves data without a hitch; the only difference is the name of one of the parameters I'm passing into my sproc.

What on earth could possibly be causing this? 

Michael Hildner replied on Tuesday, December 05, 2006

Have you seen what you're actually sending to the db via the profiler? I usually capture the profiler output, then run that through a query in management studio.

albruan replied on Tuesday, December 05, 2006

I did as you suggested and it shows the two values I'm attempting to pass to my sproc.  The profiler also shows that 2 reads were made when the statement was executed.

albruan replied on Tuesday, December 05, 2006

Hmmmm, when I copy the statement from the Profiler and attempt to run it in SQL Server Management Studio, it returns nothing.  OH!  NM!  Dyslexic typing on my part when assigning the values passed into the Criteria object....hahahaha!

Michael Hildner replied on Tuesday, December 05, 2006

You beat me to the post. Glad you figured it out.

Michael Hildner replied on Tuesday, December 05, 2006

How about when you copy what the profiler says, then paste that into a new query in management studio and run it?

Copyright (c) Marimer LLC