35 pts.
 Stored Procedure
I am calling some stored Procedure, having selct statment, after inserting some a new data entry by different stored procedure. Some times my Select stored procedure does not return any value. Data is exactly correct and when I explicitly called that SP with same data by Query analyzer, I will got the desired result. The error I have got is System.Data error in vb.Net, due to empty DataReader. Strange is that dataReader is return true when I am calling dr.read(). Not getting exact solution.

Software/Hardware used:
ASKED: February 1, 2008  2:35 PM
UPDATED: July 19, 2008  6:20 AM

Answer Wiki:
I would assume that you aren't passing the parameters to the procedure correctly. Run SQL Profiler against the SQL Server. This will tell you what the exact command being run against the SQL Server is. If when you run that you get the correct data back then the SQL Part is working correctly, and you can focus on the .NET code not working correctly. What's the exact error that you are getting?
Last Wiki Answer Submitted:  February 1, 2008  6:22 pm  by  Denny Cherry   64,520 pts.
All Answer Wiki Contributors:  Denny Cherry   64,520 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

I have got the solution, I have used architecture such that, I have got the datareader object, which I have assigned in my loca dataReader having scope in a method.

From this method I have passed my datareader with reference to a different method, where I perform the read operation.

Many times this .Net code work properly, But some times it won’t work because .Net GC already remove my datreader object, when I am passing datareader to different method.

I have change variable scope to a class level and now it will work properly. The important thing is that I am using autoclose functionality of dataReader.

 35 pts.