Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6904707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:05:41+00:00 2026-05-27T08:05:41+00:00

I am facing this problem. I have a stored procedure which returns 6 rows

  • 0

I am facing this problem. I have a stored procedure which returns 6 rows when I execute it.

But when I am retrieving the rows in my app by using ExecuteReader, it only returns only 5 rows. Why is it losing a row??

My stored procedure consists of 5 union statements which are getting filled from a single table:

 dbase.AddInParameter(cmd, "@LoginUser", DbType.String, UserID);

   try
   {
      using (IDataReader  dr = dbase.ExecuteReader(cmd))
      if (dr.Read())
      {
         dt = new DataTable("DashBoard");
         dt.Load(dr);
      }
   }

dbase is my database object. And cmd is the SqlCommand used to call the stored procedure.

UserID is parameter is passing

Stored procedure code is:

ALTER PROCEDURE [dbo].[USP_ViewAdminDashBoard](@LoginUser varchar(75)) 
    -- Add the parameters for the stored procedure here
AS
BEGIN

    SET NOCOUNT ON;
    SET DATEFORMAT DMY;
    DECLARE @LastLoginDate  as DateTime

        Select @LastLoginDate = dbo.UDF_GetLastLoginByUser(@LoginUser)
    Select 'Last Login Date', convert(varchar(12),@LastLoginDate,105)

    Union 
    Select  'Nos. Records pending for Upload' as Title, convert(varchar(5),COUNT(s.BatchID)) Total from  dbo.BREGISTRATIONENTRY s, Dbo.TBL_iBATCH B
    where  B.BatchID = s.BatchID And b.Forwarded = 0 and b.isBatchClosed = 1
END
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:05:41+00:00Added an answer on May 27, 2026 at 8:05 am

    Your first dr.Read is advancing to the first row. The DataTable.Load is reading the remaining rows but not the first row

    Use HasRows to test for existence and don’t use Read before the DataTable.Load

    Edit:

    Just load the DataTable without testing first: then test on the DataTable. There is no HasRows in the IDataReader interface.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure in sql server that returns xml. The problem I'm
I'm facing this problem again and again, but can't find any solution (except mine,
I have created a static library following this link . But I am facing
I have a problem about weblogic console. I have been facing with this problem
I am facing a small problem. I have a struct, which has a vector.
I was facing this unique problem of generating a bit-mask based on the input
I'm facing a problem with IE6. I took the toggle function from this website
I am facing a problem while creating a static cursor in DB2. This is
I am really really tired these day because of facing this problem. I am
This is a problem I have been trying to track down for a couple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.