读取Xml并存储到临时表中 [英] Read Xml and store into temp table

查看:203
本文介绍了读取Xml并存储到临时表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读取XML文件(就像asp.net中的文件浏览器一样)并将值存储在temp表中(LINQ是可选的).由于我是桌面应用程序的新手,因此代码非常容易理解.
谢谢ADvance.

I want to read XML file(just like file browser in asp.net) and store the value in the temp table(LINQ is an optional). Since I am new to desktop application codes are highly appreciable.
Thank you in ADvance.

推荐答案

您好,Purushottam希望对您有所帮助,

Hi Purushottam hope this wil help full,

//creating a data table to store      
  DataTable dt = new DataTable();
      

//give the path of the xml file or name if it is in current directory
        dt.ReadXml("Read.xml");

//dt is the table holding values set from the xml now we can write it to 
//the sql database


string strConnectionString = @"Data Source=xyzYY\SQLEXPRESS;Initial Catalog=TrackerDB;User ID=admin;Password=wxyz;"; 
               SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnectionString);sqlBulk.DestinationTableName = "dbo.Quote_Staging"; sqlBulk.WriteToServer(dt);
               sqlBulk.Close();


看看:
http://blog .sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/ [
Have a look at :
http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/[^]


这篇关于读取Xml并存储到临时表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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