在C#中编写一个更新查询以删除续价,然后将其发送到sql数据库 [英] Writing an update query within C# to remove carrage returns and then send to a sql database

查看:103
本文介绍了在C#中编写一个更新查询以删除续价,然后将其发送到sql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码.粗体字是我要达到的目标.任何帮助将不胜感激.

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();
        }
    }
}

推荐答案

1.要保存和加载XML数据,请参阅此代码项目文章使用序列化将对象加载和保存到XML [ ^ ]
2.要将数据保存到SQL数据库,请查看此 MSDN [
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.


这篇关于在C#中编写一个更新查询以删除续价,然后将其发送到sql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆