C#从数据库读取数据到DataSet并保存到xml文件
using System;
using System.Data;
using System.Xml;
using System.Data.SqlClient;
using System.IO; public class TestWriteXML
{
public static void Main()
{
String strFileName = c:/temp/out.xml;
SqlConnection conn = new SqlConnection(server=localhost;uid=sa;pwd=;database=db);
String strSql = SELECT name,age FROM people;
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand(strSql, conn);
// Build the DataSet
DataSet ds = new DataSet();
adapter.Fill(ds, employees);
// Get a FileStream object
FileStream fs = new FileStream(strFileName, FileMode.OpenOrCreate, FileAccess.Write);
// Apply the WriteXml method to write an XML document
ds.WriteXml(fs);
fs.Close();
}
}
//该代码片段来自于: http://www.sharejs.com/codes/csharp/7773
C#从数据库读取数据到DataSet并保存到xml文件的更多相关文章
- 10天学会phpWeChat——第三天:从数据库读取数据到视图
在第二天,我们创建了我们的第一个phpWeChat功能模块,但是比较简单.实际生产环境中,我们不可能有如此简单的需求.更多的情况是数据存储在MySql数据库中,我们开发功能模块的作用就是将这些数据从M ...
- echarts通过ajax向服务器发送post请求,servlet从数据库读取数据并返回前端
1.echarts的官网上的demo,都是直接写死的随机数据,没有和数据库的交互,所以就自己写了一下,ok,我们开始一步一步走一遍整个流程吧. 就以官网最简单的那个小demo来做修改吧.官网上的小de ...
- C#实现从数据库读取数据到Excel
用第三方组件:NPOI来实现 先去官网:http://npoi.codeplex.com/下载需要引入dll(可以选择.net2.0或者.net4.0的dll),然后在网站中添加引用.使用 NPOI ...
- JMeter 参数化之利用JDBCConnectionConfiguration从数据库读取数据并关联变量
参数化之利用DBC Connection Configuration从数据库读取数据并关联变量 by:授客 QQ:1033553122 1. 下载mysql jar包 下载mysql jar包 ...
- Android打开数据库读取数据
打开数据库读取数据 private MyDatabaseHelper dbHelper; dbHelper=new MyDatabaseHelper(this,"List.db", ...
- 使用pandas中的raad_html函数爬取TOP500超级计算机表格数据并保存到csv文件和mysql数据库中
参考链接:https://www.makcyun.top/web_scraping_withpython2.html #!/usr/bin/env python # -*- coding: utf-8 ...
- 记录python爬取猫眼票房排行榜(带stonefont字体网页),保存到text文件,csv文件和MongoDB数据库中
猫眼票房排行榜页面显示如下: 注意右边的票房数据显示,爬下来的数据是这样显示的: 网页源代码中是这样显示的: 这是因为网页中使用了某种字体的缘故,分析源代码可知: 亲测可行: 代码中获取的是国内票房榜 ...
- iOS开发——数据持久化&本地数据的存储(使用NSCoder将对象保存到.plist文件)
本地数据的存储(使用NSCoder将对象保存到.plist文件) 下面通过一个例子将联系人数据保存到沙盒的“documents”目录中.(联系人是一个数组集合,内部为自定义对象). 功能如下: ...
- 转载 Silverlight实用窍门系列:1.Silverlight读取外部XML加载配置---(使用WebClient读取XAP包同目录下的XML文件))
转载:程兴亮文章,地址;http://www.cnblogs.com/chengxingliang/archive/2011/02/07/1949579.html 使用WebClient读取XAP包同 ...
随机推荐
- git小操作之checkout、stash
git checkout会带上当前changed但没有commit的内容到目标分支 git stash用来暂存当前改动,并且会退代码到上一个commit:git stash pop则取出所stash的 ...
- 关于Android studio 相对 eclipse 优点
优点:说法一 1.Google推出的,这个是它的最大优势,Android Stuido是Google推出,专门为Android"量身订做"的 2.速度更快,Eclipse的启动速度 ...
- 下拉列表autocomplete各种实现方式比较
方法一:用form 表单的datalist属性,此时会以首字母补充排序.实现效果参考:http://www.w3schools.com/html/tryit.asp?filename=tryhtml_ ...
- 从手工测试转型web自动化测试继而转型成专门做自动化测试的学习路线。
在开始之前先自学两个工具商业web自动化测试工具请自学QTP:QTP的学习可以跳过,我是跳过了的.开源web自动化测试工具请自学Selenium:我当年是先学watir(耗时1周),再学seleniu ...
- Can brain stimulation aid memory and brain health?
Can brain stimulation aid memory and brain health? Harvard Women’s Health Watch Image: Thinkstock Th ...
- linux中强大且常用命令:find、grep
在linux下面工作,有些命令能够大大提高效率.本文就向大家介绍find.grep命令,他哥俩可以算是必会的linux命令,我几乎每天都要用到他们. 本文结构如下: find命令 find命令的一般形 ...
- Java中自定泛型方法
泛型用到哪些集合:List Set Map List<String> list=new ArraList<String>(); list.add("美女") ...
- iOS地址编码解析
- (void)viewDidLoad { [super viewDidLoad]; // 创建地址解析器 self.geocoder = [[CLGeocoder alloc] init]; } - ...
- APUE第4章 文件和目录
4.2 文件函数 #include <sys/stat.h> int stat(const char *restrict pathname, struct stat *restrict b ...
- 【WCF】Silverlight+wcf+自定义用户名密码验证
本文摘自 http://www.cnblogs.com/virusswb/archive/2010/01/26/1656543.html 在昨天的博文Silverlight3+wcf+在不使用证书的情 ...