Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Here is my Code. The areas in bold is what I am trying to achieve. Any help would be greatly appreciated.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Data.SqlClient;


namespace XMLReader
{
    public partial class XMLReaderControl : Form
    {
        //Name of DataGrid
        public string strTableName = "";
        

        public XMLReaderControl()
        {
            //Table file name is Malfunction.xml
            InitializeComponent();
            strTableName = "Malfunction";
            TableDisplay.Text = strTableName;


        }

        private void btnReader_Click(object sender, EventArgs e)
        {

            string strFilePath = "";
            string strOutput = "";



            // Read XML data into a DataSet
            DataSet ds = new DataSet("ds");

            //Path to the XML file
            strFilePath = @"C:\Users\jeremyn\Desktop\Programs\XMLReader\Malfunction.xml";
            ds.ReadXml(strFilePath);

            //dataGridView1.DataSource = ds;
            TableDisplay.DataSource = ds.Tables[strTableName];

            // Read a DataSet into an XML document
            System.Xml.XmlDataDocument xmlDataDoc = new XmlDataDocument(ds); 
           // trying to find an alternet for the XMLDataDocument.
            strOutput = xmlDataDoc.InnerXml;
            XMLDisplay.Text = strOutput;

        }

        private void btnConvert_Click(object sender, EventArgs e)
       
        {
/* When this button is clicked I want it to update the xml so that it changes the carrage returns, within all the rows, shows the change within the text view box, and then brings up a window with the option to submit to an sql database.*/ 
        }
        


        private void btnExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
Posted
Updated 1-Jun-11 13:29pm
v2

1 solution

1. For saving and loading XML data take a look this Code Project article, Load and save objects to XML using serialization[^]
2. For saving data to SQL Database,take a look this MSDN[^] article.

Note: I am assuming that your back end database is SQL Server.
 
Share this answer
 
Comments
jeremy1973 2-Jun-11 5:21am    
Yes. I am trying to change the carriage returns within the XML file before it gets sent back to SQL Database. I know the line for SQL is something like UPDATE Name of file SET Name of file.effect = Replace([Effect],"^",Char(13) & Char(10));. But I am trying to run this code within a C# app to manipulate the XML first.
Wonde Tadesse 2-Jun-11 7:33am    
Since you didn't provide the XML structure ,it's difficult to provide what you want.The links are just to give you an insight how to do things with xml and database.

Good luck

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900