惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
C
CERT Recently Published Vulnerability Notes
P
Proofpoint News Feed
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
云风的 BLOG
云风的 BLOG
H
Help Net Security
Recorded Future
Recorded Future
The Register - Security
The Register - Security
F
Full Disclosure
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hackread – Cybersecurity News, Data Breaches, AI and More
爱范儿
爱范儿
Security Archives - TechRepublic
Security Archives - TechRepublic
Simon Willison's Weblog
Simon Willison's Weblog
Cisco Talos Blog
Cisco Talos Blog
I
InfoQ
T
Tenable Blog
T
Tor Project blog
人人都是产品经理
人人都是产品经理
D
DataBreaches.Net
NISL@THU
NISL@THU
Google DeepMind News
Google DeepMind News
博客园 - 叶小钗
B
Blog
V
V2EX
Jina AI
Jina AI
L
LangChain Blog
月光博客
月光博客
W
WeLiveSecurity
U
Unit 42
AWS News Blog
AWS News Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
博客园 - 聂微东
V
Visual Studio Blog
A
Arctic Wolf
T
Tailwind CSS Blog
The Cloudflare Blog
SecWiki News
SecWiki News
S
SegmentFault 最新的问题
Hacker News - Newest:
Hacker News - Newest: "LLM"
宝玉的分享
宝玉的分享
MyScale Blog
MyScale Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Securelist
www.infosecurity-magazine.com
www.infosecurity-magazine.com
腾讯CDC
雷峰网
雷峰网

博客园 - 嚣张的沉默

读写txt文档 限制TextBox输入字数 计算TextBox输入的字数 我常用的正则与SQL语句 DataSet导入到Excel 年月日联动的JS代码 用户控件的传值方法 Repeater模板列 asp.net的几个小技巧 百叶窗效果 建站安全 倒计时代码 解决SQL2000安装服务器挂起 删除.NET的最近项目 屏幕右下角弹出广告 上传图片重命名并创建文件夹 自动跳转页面带参数 微软出的AJAX控件的安装(转载) 第一次开博
DataSet写入、导出XML
嚣张的沉默 · 2007-11-06 · via 博客园 - 嚣张的沉默

写入到XML中

SqlConnection conn = new SqlConnection("server=.;uid=sa;database=RunSkyDB");
        SqlCommand comm 
= new SqlCommand("select *from Telephote", conn);
        conn.Open();
        SqlDataReader dr 
= comm.ExecuteReader();
        DataTable dt 
= new DataTable("table"); //如果操作单个表,这样比用DataSet会好些
        dt.Load(dr); //这个ADO.NET 1.x中没有这个功能,确实是个突破
        dt.WriteXml(Server.MapPath("~/EppUser.xml"), true); //将dt中的数据记录写成xml并存入项目的根目录下
        dt.WriteXmlSchema(@"d:\EpUserschema1.xml");//将dt的数据结构写入磁盘中
        GridView1.DataSource = dt;//将dt中的数据绑定到dataGridView1中
        dr.Close();
        conn.Close();

读出:

DataSet ds = new DataSet();
        ds.ReadXml(Server.MapPath(
"~/EppUser.xml"));
        GridView1.DataSource 
= ds.Tables[0].DefaultView;
        GridView1.DataBind();