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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:20:39+00:00 2026-06-04T01:20:39+00:00

I’m looking for the simplest way to pass an xml file as a store

  • 0

I’m looking for the simplest way to pass an xml file as a store procedure parameter using c#.Actually I need to create an xml file for the purpose of save this xml into the sql database.In database store procedure there has a parameter as xml type. I have already created a xml file stated bellow

 StringWriter stringWriter = null;
 XmlTextWriter writer = null;
 try
 {
  stringWriter = new StringWriter(new StringBuilder());
  writer = new XmlTextWriter(stringWriter);
  writer.Formatting = Formatting.Indented;
  writer.WriteStartDocument();
  writer.WriteComment("Holiday Info");

  writer.WriteStartElement("holidayInfo", "");

  for (int groupIndex = 0; groupIndex < numberOfGroup; groupIndex++)
        {
            for (int religionIndex = 0; religionIndex < numberOfReligion; religionIndex++)
            {
                for (int jobStationIndex = 0; jobStationIndex < numberOfJobStation; jobStationIndex++)
                {
                    writer.WriteStartElement("HOLIDAY", ""); 
                    writer.WriteAttributeString("intGroupID", chkGroupList.Items[groupIndex].Value.ToString());
                    writer.WriteAttributeString("intJobTypeId", "0");
                    writer.WriteAttributeString("intJobStationID", chkReligionList.Items[religionIndex].Value.ToString());
                    writer.WriteAttributeString("intHolidayID", ddlHolidayName.SelectedValue.ToString());
                    writer.WriteAttributeString("dtePermitedDate", DateTime.Now.ToShortDateString());
                    writer.WriteAttributeString("intReligionId", chkReligionList.Items[religionIndex].Value.ToString());
                    writer.WriteAttributeString("dteFromDate", txtFromDate.Text);
                    writer.WriteAttributeString("dteToDate", txtToDate.Text);
                    writer.WriteEndElement();
                }
            }

        }
      stringWriter.GetStringBuilder().ToString();
      return will be what if i want to sent this file to the store procedure parameter?;
    }
    finally
    {
        if (writer != null) writer.Close();
        if (stringWriter != null) stringWriter.Close();
    }

return type will be what if i want to sent this file to the store procedure as xml parameter?

This is my store Procedure

CREATE PROCEDURE [dbo].[sprHoliday_InsertHolidaysGroupPermission]
@intUserID INT =NULL,
@xmlHolidayPermissionDetails XML,
@insertStatus AS VARCHAR(200) OUT
AS
BEGIN
DECLARE @intEmployeeID int
IF (@intUserID IS NOT NULL)
BEGIN
    SELECT @intEmployeeID = intEmployeeID From dbo.tblUserInfo WHERE   tblUserInfo.intUserID = @intUserID       
END 

BEGIN TRANSACTION
BEGIN TRY
   INSERT INTO  dbo.tblEmployeeGroupPermissionHolidays
                (intGroupID,
                 intJobTypeId,
                 intJobStationID,
                 intHolidayID,
                 dtePermitedDate,
                 intReligionId,
                 dteFromDate,
                 dteToDate)
        (SELECT  xmlHolidayPermissionDetails.item.value('@intGroupID[1]', 'INT'),
                 xmlHolidayPermissionDetails.item.value('@intJobTypeId[1]', 'INT'),
                 xmlHolidayPermissionDetails.item.value('@intJobStationID[1]', 'INT'),
                 xmlHolidayPermissionDetails.item.value('@intHolidayID[1]', 'INT'),
                 xmlHolidayPermissionDetails.item.value('@dtePermitedDate[1]', 'DATE'),
                 xmlHolidayPermissionDetails.item.value('@intReligionId[1]', 'INT'),
                 xmlHolidayPermissionDetails.item.value('@dteFromDate[1]', 'DATE'),
                 xmlHolidayPermissionDetails.item.value('@dteToDate[1]', 'DATE')
          FROM   @xmlHolidayPermissionDetails.nodes('//HOLIDAY') AS xmlHolidayPermissionDetails(item)
         )
   COMMIT 
   INSERT INTO dbo.tblHRDataHistory values('Insert','Holiday Permission Data Insert','tblEmployeeGroupPermissionHolidays',GETDATE(),@intEmployeeID)
   SET @insertStatus = 'Holiday Permission has been iserted succesfully' 
 END TRY

 BEGIN CATCH
 Rollback
 SELECT @insertStatus = 'There was an error! ' + ERROR_MESSAGE()
 END CATCH 

 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-06-04T01:20:41+00:00Added an answer on June 4, 2026 at 1:20 am
    System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
    doc.LoadXml(string);
    

    This should work.

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

Sidebar

Related Questions

In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
I'm parsing an XML file, the creators of it stuck in a bunch social
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.