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 8807495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:22:50+00:00 2026-06-14T02:22:50+00:00

I have a stored procedure that executes perfectly in SQL Server. However I am

  • 0

I have a stored procedure that executes perfectly in SQL Server. However I am not able to access the rows that are return by it in asp.net from Data Access Layer

My DataAccessLayer code is as follows:

 public List<AdvancePaymentRep> getPaymentAdvanceData(int? InternalCompany = 0, string Currency = "", DateTime? InvoiceDateFrom = null, DateTime? InvoiceDateTo = null, DateTime? AdvDateDueFrom = null, DateTime? AdvDateDueTo = null)
    {
      CreateConnectionString();
      List<AdvancePaymentRep> paymentAdvanceCollection = new List<AdvancePaymentRep>();
      SqlDataReader rdrval = null;
      SqlCommand command1 = sqlConnection.CreateCommand();
      command1.CommandType = System.Data.CommandType.StoredProcedure;
      command1.CommandText = "[dbo].[NST_GetDataForAdvancePaymentReport]";

      if (InternalCompany != 0)
      {

        SqlParameter parametersInternalCompany = new SqlParameter();
        parametersInternalCompany.ParameterName = "@AlhInternalCie";
        parametersInternalCompany.SqlDbType = System.Data.SqlDbType.Int;
        parametersInternalCompany.Direction = ParameterDirection.Input;
        parametersInternalCompany.Value = InternalCompany;
        command1.Parameters.Add(parametersInternalCompany);
      }

      SqlParameter parametersCurrency = new SqlParameter();
      parametersCurrency.ParameterName = "@AlhCurrency";
      parametersCurrency.SqlDbType = System.Data.SqlDbType.NVarChar;
      parametersCurrency.Direction = ParameterDirection.Input;
      parametersCurrency.Value = Currency;
      command1.Parameters.Add(parametersCurrency);

      if (InvoiceDateFrom != Convert.ToDateTime("01/01/0001 00:00:00"))
      {

        SqlParameter parametersInvoiceDateFrom = new SqlParameter();
        parametersInvoiceDateFrom.ParameterName = "@AldDtCreatedFrom";
        parametersInvoiceDateFrom.SqlDbType = System.Data.SqlDbType.Date;
        parametersInvoiceDateFrom.Direction = ParameterDirection.Input;
        parametersInvoiceDateFrom.Value = InvoiceDateFrom;
        command1.Parameters.Add(parametersInvoiceDateFrom);
      }

      if (InvoiceDateTo != Convert.ToDateTime("01/01/0001 00:00:00"))
      {
        SqlParameter parametersInvoiceDateTo = new SqlParameter();
        parametersInvoiceDateTo.ParameterName = "@AldDtCreatedTo";
        parametersInvoiceDateTo.SqlDbType = System.Data.SqlDbType.Date;
        parametersInvoiceDateTo.Direction = ParameterDirection.Input;
        parametersInvoiceDateTo.Value = InvoiceDateTo;
        command1.Parameters.Add(parametersInvoiceDateTo);

      }

      if (AdvDateDueFrom != Convert.ToDateTime("01/01/0001 00:00:00"))
      {
        SqlParameter parametersInvoiceDateDueFrom = new SqlParameter();
        parametersInvoiceDateDueFrom.ParameterName = "@InvhDtDueFrom";
        parametersInvoiceDateDueFrom.SqlDbType = System.Data.SqlDbType.Date;
        parametersInvoiceDateDueFrom.Direction = ParameterDirection.Input;
        parametersInvoiceDateDueFrom.Value = AdvDateDueFrom;
        command1.Parameters.Add(parametersInvoiceDateDueFrom);
      }


      if (AdvDateDueTo != Convert.ToDateTime("01/01/0001 00:00:00"))
      {
        SqlParameter parametersInvoiceDateDueTo = new SqlParameter();
        parametersInvoiceDateDueTo.ParameterName = "@InvhDtDueTo";
        parametersInvoiceDateDueTo.SqlDbType = System.Data.SqlDbType.Date;
        parametersInvoiceDateDueTo.Direction = ParameterDirection.Input;
        parametersInvoiceDateDueTo.Value = AdvDateDueTo;
        command1.Parameters.Add(parametersInvoiceDateDueTo);
      }

      try
      {
        if (sqlConnection == null)
        {
          sqlConnection.Open();
        }
        rdrval = command1.ExecuteReader(); // Getting HasRows = false out here 

EDIT : Have solved the issue there was some problem with how i had supplied the

  • 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-06-14T02:22:51+00:00Added an answer on June 14, 2026 at 2:22 am

    The last command in your SP should be a SELECT command. Else, you get other results such as the number of rows affected and such. Management Studio is still able to display rows created from one of the SELECTs in your SP but actually they are not the first “thing” that is returned when you call an ADO.NET command against that SP.

    • 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 that executes much faster from Sql Server Management Studio
All, I have a stored procedure on SQL Server 2005 that accepts an XML
I have a Winforms application that executes a stored procedure which examines several rows
I'm working with sql server 2008r2 developer. I have a stored procedure that adds
I have a stored procedure that has this line: SET @SQL = 'SELECT path,title,tags
I have a stored procedure which executes some dynamic sql, shown below. I've tried
I have a stored procedure that uses a table valued function which executes in
I have a webservice method that executes a tabular stored procedure. This sp takes
I have a SQL stored procedure that I need to execute several times with
I have a search function that executes a stored procedure and returns results. If

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.