在没有SQL Server数据库的情况下以编程方式使用DataSet [英] using DataSet programatically without an sql server database

查看:60
本文介绍了在没有SQL Server数据库的情况下以编程方式使用DataSet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要自定义构建并使用c#中的数据集与xml一起使用。有没有人

知道我在哪里可以找到如何做这样的事情?我打算用
创建一个生成数据集及其数据的类来隐藏所有的

复合体(或者我应该说是巨大的代码块)本身。

I need to custom build and use a dataset in c# to use with xml. Does anybody
know where I can find out how to do something like this? I was going to
create a class that generated the dataset and its data to hide all of the
complex (or should I say the huge chuncks of code) from the page itself.

推荐答案

嗨Andy,


我不太清楚你的要求是什么但是如果你想从一些XML而不是从SQL Server中的某个数据库中填充数据集,那么你可以在C#中的代码中创建一个新的数据集。然后将XML文件

读入该数据集。请找到下面的代码。


DataSet ds = new DataSet();

ds.ReadXml(" XML文件的路径);


问候,

Manish
www.componentone.com

" Andy B"写道:
Hi Andy,

I am not quite sure what your requirement is but if you want to populate
your dataset from some XML and not from some database in the SQL Server then
you can create a new dataset in your code in C# and then read the XML file
into that dataset. Please find the code below.

DataSet ds= new DataSet();
ds.ReadXml("path of the XML file");

Regards,
Manish
www.componentone.com
"Andy B" wrote:

我需要自定义构建并使用c#中的数据集与xml一起使用。有没有人

知道我在哪里可以找到如何做这样的事情?我打算用
创建一个生成数据集及其数据的类来隐藏所有的

复合体(或者我应该说是巨大的代码块)本身。

I need to custom build and use a dataset in c# to use with xml. Does anybody
know where I can find out how to do something like this? I was going to
create a class that generated the dataset and its data to hide all of the
complex (or should I say the huge chuncks of code) from the page itself.


我主要是寻找一种以编程方式创建和填充列的方法

和手动行代替使用xml或数据库。

" Manish" < Ma **** @ discussion.microsoft.com写信息

新闻:3F ************************ ********** @ microsof t.com ...
I am mainly looking for a way to programatically create and populate columns
and rows manually instead of with xml or a database.
"Manish" <Ma****@discussions.microsoft.comwrote in message
news:3F**********************************@microsof t.com...

嗨Andy,


我我不太确定你的要求是什么,但如果你想从一些XML填充数据集,而不是从SQL Server中的某个数据库填充

那么

您可以在C#中的代码中创建一个新数据集,然后将XML文件

读入该数据集。请找到下面的代码。


DataSet ds = new DataSet();

ds.ReadXml(" XML文件的路径);


问候,

Manish
www.componentone.com


" Andy B"写道:
Hi Andy,

I am not quite sure what your requirement is but if you want to populate
your dataset from some XML and not from some database in the SQL Server
then
you can create a new dataset in your code in C# and then read the XML file
into that dataset. Please find the code below.

DataSet ds= new DataSet();
ds.ReadXml("path of the XML file");

Regards,
Manish
www.componentone.com
"Andy B" wrote:

>我需要自定义构建并使用c#中的数据集与xml一起使用。是否

知道我在哪里可以找到如何做这样的事情?我打算创建一个生成数据集及其数据的类来隐藏页面本身的所有复杂(或者我应该说是巨大的代码)。

>I need to custom build and use a dataset in c# to use with xml. Does
anybody
know where I can find out how to do something like this? I was going to
create a class that generated the dataset and its data to hide all of the
complex (or should I say the huge chuncks of code) from the page itself.



" Andy B" < a _ ***** @ sbcglobal.netwrote in message

news:uN ************** @ TK2MSFTNGP03.phx.gbl ...


[top-posting更正]
"Andy B" <a_*****@sbcglobal.netwrote in message
news:uN**************@TK2MSFTNGP03.phx.gbl...

[top-posting corrected]

> >我需要自定义构建并使用c#中的数据集与xml一起使用。是否

知道我在哪里可以找到如何做这样的事情?我打算创建一个生成数据集及其数据的类来隐藏页面本身的所有复杂(或者我应该说是巨大的代码块)。
>>I need to custom build and use a dataset in c# to use with xml. Does
anybody
know where I can find out how to do something like this? I was going to
create a class that generated the dataset and its data to hide all of
the
complex (or should I say the huge chuncks of code) from the page itself.


我不太确定您的要求是什么,但是如果您想从某些XML填充数据集而不是从SQL Server中的某个数据库填充
那么
您可以在C#中的代码中创建一个新数据集,然后将XML
文件读入该数据集。请找到下面的代码。

DataSet ds = new DataSet();
ds.ReadXml(" XML文件的路径);


I am not quite sure what your requirement is but if you want to populate
your dataset from some XML and not from some database in the SQL Server
then
you can create a new dataset in your code in C# and then read the XML
file
into that dataset. Please find the code below.

DataSet ds= new DataSet();
ds.ReadXml("path of the XML file");



我主要是寻找一种以编程方式手动创建和填充

列和行的方法,而不是使用xml或数据库。


I am mainly looking for a way to programatically create and populate
columns and rows manually instead of with xml or a database.



使用(DataTable objDT = new DataTable())

{

objDT.Columns.Add(" ; First",typeof(string));

objDT.Columns.Add(" Second",typeof(string));

objDT.Columns.Add(" ; Third",typeof(string));

objDT.Columns.Add(" Fourth",typeof(string));

objDT.Rows.Add(new object [4] {R1C1,R1C2,R1C3,R1C4});

objDT.Rows.Add(new object [4] {" R2C1" ;,R2C2,R2C3,R2C4});

objDT.Rows.Add(新对象[4] {" R3C1",R3C2"," R3C3,R3C4}};

objDT.Rows.Add(新对象[4] {R4C1,R4C2,R4C3,R4C4; });

MyGridView.DataSource = objDT;

MyGridView.DataBind();

}

-

Mark Rae

ASP.NET MVP
http://www.markrae.net

using (DataTable objDT = new DataTable())
{
objDT.Columns.Add("First", typeof(string));
objDT.Columns.Add("Second", typeof(string));
objDT.Columns.Add("Third", typeof(string));
objDT.Columns.Add("Fourth", typeof(string));
objDT.Rows.Add(new object[4] { "R1C1", "R1C2", "R1C3", "R1C4" });
objDT.Rows.Add(new object[4] { "R2C1", "R2C2", "R2C3", "R2C4" });
objDT.Rows.Add(new object[4] { "R3C1", "R3C2", "R3C3", "R3C4" });
objDT.Rows.Add(new object[4] { "R4C1", "R4C2", "R4C3", "R4C4" });
MyGridView.DataSource = objDT;
MyGridView.DataBind();
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


这篇关于在没有SQL Server数据库的情况下以编程方式使用DataSet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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