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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:43:21+00:00 2026-06-06T17:43:21+00:00

I am facing a issue here in reading the values set by a stored

  • 0

I am facing a issue here in reading the values set by a stored procedure in C#.

  1. I have a stored procedure which sets variables @errorCode @errorStr to 0 and “Failed” on failure of a stored procedure.

  2. I have a C# function which invokes the Stored Procedure and the value is set correctly but I am not able to read the values of @errorCode and @errorStr through my C# code.

  3. My code goes as follows


string op = null;

cmd.CommandText = "PopulateAnswers";
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter("@i_xmlreq", SqlDbType.Xml);
param.Value = xmltext;
param.Direction = ParameterDirection.Input;
cmd.Parameters.Add(param);     
cmd.Connection = Conn1;   
SqlDataReader dataReader = cmd.ExecuteReader();

if (dataReader.HasRows)
{
    op = dataReader.GetValue(1).ToString();

    if (op.CompareTo("Failed To set Answers") == 0)
    {
        WriteErrorLog("Failed to execute the stored Procedure");
        return "1:Failed to execute stored procedure ";
    }
    else
    {
        return "0:success";
    }
}

I am getting an error while I am trying to read the data. It says that you are trying to read a value which does not exist. But I am able to see the values properly when I hover over the variable datareader. It’s present under Datareader -> Results view -> [0] -> Non-static .

  • 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-06T17:43:23+00:00Added an answer on June 6, 2026 at 5:43 pm

    You need to call dataReader.Read() before you can get the values.

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

Sidebar

Related Questions

I have been facing issue with sphinx result set for string attribute. Below is
We have implemented webservice which generates xml response. I am facing issue while invoking
I'm facing an issue here. For Facebook debugging reasons, I made a host entry
I am facing issue with proper date retrieval using date formatter.I have saved the
ghost noscript tag more info here I am facing exactly this issue, how shall
so I'm facing an issue here that I'm sure many a developer before me
I am working on a C# application and facing a strange issue here. I
I am facing an issue with back ground image in ie8. Here is the
I am facing an issue with this simple jQuery code. I have attached the
I am a newbie to Qt and facing issue in my application. So here

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.