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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:18:36+00:00 2026-05-28T03:18:36+00:00

I am having a strange message displayed on the asp:label when trying to display

  • 0

I am having a strange message displayed on the asp:label when trying to display data from a database. During page_load the asp:label is meant to be populated from a datasource however is displays the following message/text “System.Data.SqlClient.SqlDataReader”

What could be causing this?

I have written a small method in the page load of the .aspx.cs page.
labelName is the one which is displaying this message:

public partial class edit_questionnaire : System.Web.UI.Page
    {
        OsqarSQL GetData;

        protected void Page_Load(object sender, EventArgs e)
        {
            string questionnaireId = Session["qID"].ToString();
            int qid = Convert.ToInt32(questionnaireId);
            GetData = new OsqarSQL();
            string name = GetData.GetQuestionnaireName(qid);
            labelName.Text = name;

        }
    }

Which calls the following method:

public string GetQuestionnaireName(int questionnaireId)
        {
            string returnValue = string.Empty;
            SqlCommand myCommand = new SqlCommand("GetQuestionnaireName", _productConn);
            myCommand.CommandType = CommandType.StoredProcedure;
            myCommand.Parameters.Add(new SqlParameter("@QUEST_ID", SqlDbType.Int));
            myCommand.Parameters[0].Value = questionnaireId;
            SqlDataReader qName = getData(myCommand);
            while (qName.Read())
            {
               returnValue = qName.ToString();
            }
            _productConn.Close();
            return returnValue;
        }

And uses this stored procedure:

ALTER PROCEDURE [hgomez].[GetQuestionnaireName] 
    (
    @QUEST_ID int
    )   
AS
    /*SET NOCOUNT ON;*/
    SELECT QuestionnaireName FROM [Questionnaires] WHERE QuestionnaireID = @QUEST_ID
    RETURN
  • 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-28T03:18:37+00:00Added an answer on May 28, 2026 at 3:18 am
    public string GetQuestionnaireName(int questionnaireId)
        {
            string returnValue = string.Empty;
            SqlCommand myCommand = new SqlCommand("GetQuestionnaireName", _productConn);
            myCommand.CommandType = CommandType.StoredProcedure;
            myCommand.Parameters.Add(new SqlParameter("@QUEST_ID", SqlDbType.Int));
            myCommand.Parameters[0].Value = questionnaireId;
            SqlDataReader qName = getData(myCommand);
            while (qName.Read())
            {
               returnValue = qName[0].ToString();
            }
            _productConn.Close();
            return returnValue;
        }
    

    You were assigning the SqlDataReader to your returnValue rather than reading the value.

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

Sidebar

Related Questions

I'm having a strange problem here... I have an ASP.NET 3.5 application that has
I am having a strange compile time error message when attempting to compile one
I'm having trouble using Simple Xml Serializer to build a Message from a complex
I've been trying to understand Oracle database's use of data type = number. I
I'm trying to get a simple Lift example running and I'm having a strange
Having a strange issue with some C# code - the Getter method for a
I am having a strange DB2 issue when I run DBUnit tests. My DBUnit
I'm having a strange problem. I have to use GetPostBackEventRefence to force a Postback,
I'm having a strange problem in Visual Studio 2008 where my Pending Checkins window
I'm having some strange problems copying files in a custom script in TFS2008 without

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.