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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:01:10+00:00 2026-06-10T17:01:10+00:00

I have an XML stored in the database table that I am trying to

  • 0

I have an XML stored in the database table that I am trying to retrieve (variable strXML) below. Any reason why this is coming as blank? Please help. When I execute the procedure directly in database, it’s working fine.

        try
        {
            // Open the database connection
            using (SqlConnection myConn = my.openConnection("~",PConnectionString"))
            {
                // Initialize the SQL command object.
                using (SqlCommand myCOmmand = new SqlCommand("getCycleXML", myConn))
                {
                    myCOmmand.CommandType = CommandType.StoredProcedure;
                    // Add the parameters

                    SqlParameter parameter2 = new SqlParameter("@emailID", SqlDbType.NVarChar, 128);
                    parameter2.Value = strEmailID;
                    parameter2.Direction = ParameterDirection.Input;
                    myCOmmand.Parameters.Add(parameter2);

                    SqlParameter parameter1 = new SqlParameter("@pCode", SqlDbType.VarChar, 50);
                    parameter1.Value = strPCode;
                    parameter1.Direction = ParameterDirection.Input;
                    myCOmmand.Parameters.Add(parameter1);

                    SqlParameter parameter7 = new SqlParameter("@cID", SqlDbType.Int);
                    parameter7.Direction = ParameterDirection.Input;
                    parameter7.Value = icID;
                    myCOmmand.Parameters.Add(parameter7);

                    SqlParameter parameter9 = new SqlParameter("@cycleXML", SqlDbType.Xml);
                    parameter9.Direction = ParameterDirection.Output;
                    myCOmmand.Parameters.Add(parameter9);


                    SqlParameter parameter10 = new SqlParameter("@msg", SqlDbType.VarChar, 50);
                    parameter10.Direction = ParameterDirection.Output;
                    myCOmmand.Parameters.Add(parameter10);

                    SqlParameter parameter11 = new SqlParameter("@Success", SqlDbType.Int);
                    parameter11.Direction = ParameterDirection.Output;
                    myCOmmand.Parameters.Add(parameter11);
                    //Execute the command

                    myCOmmand.ExecuteNonQuery();
                    // Read the values of the output parameters
                    strXML = myCOmmand.Parameters["@cycleXML"].Value.ToString();

                   =================================================

Stored procedure definition is as follows:

  USE [DMac]
  GO

  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO

  CREATE PROCEDURE [dbo].[getCycleXML]
  @emailID Nvarchar(128),
  @cID varchar(50),
  @pCode varchar(50),
  @cycleXML xml output,
  @Success int output, 
  @msg varchar(50) output  

  AS
  BEGIN
  select XMLDefectCycle from dbo.CycleXML where EmailID=@emailID and PCode=@pCode and CID=@cID 
  END

==============================

Why the code is coming back as a blank XML. I checked that for the given parameters in the database I was expecting an XML from the database.

  • 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-10T17:01:11+00:00Added an answer on June 10, 2026 at 5:01 pm

    You’re not setting the output parameter in your stored procedure

    It should be

    select @cycleXML = XMLDefectCycle 
    from dbo.CycleXML where EmailID=@emailID and PCode=@pCode and CID=@cID  
    

    or call your stored procedure with ExecuteScalar() instead

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

Sidebar

Related Questions

I have stored the XML path to items in a string like this: response->items->item
I have a C# application that calls a stored procedure that produces an xml
I have an HTML/XML table generated by AJAX that displays limited columns of a
I have xml files been imported onto an FTP server. This is stored in
I try to write tests using php for database. I have a table that
I have a stored procedure that updates my database. It runs great in query
I have created a table that has a strongly type XML column in SQL2008
Here's the scenario: I'm working with a database table that stores an XML string
Suppose I have an XML document stored as an Anti-XML Elem : val root
I have a set of records, stored as XML files, where the XML files

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.