XSD VS.Net [英] XSD VS.Net

查看:63
本文介绍了XSD VS.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vs.net中配置关系数据模式(MyDataSet.xsd)之后,您使用什么

代码在两个下拉列表控件中显示该数据(

parent / web)在web应用程序中?

After configuring a relation data schema (MyDataSet.xsd) in vs.net, what
code do you use to display that data within two dropdownlist controls (
parent/child) in an web application?

推荐答案

嗨Leon,


配置类型化数据集只能得到你在那里的一半(假设你用XSD做的'b
)。你还需要手工做的是

编写一些ADO.NET代码来建立与数据库的连接,并实际加载数据集中的东西。例如,您可以定义一个

SqlDataAdapter,指定一个SELECT ...查询并使用.Fill和您键入的

DataSet作为参数(如果您使用SQL Server)。

定义类型化数据集并仅使用DataAdapter填充两个下拉列表可能有点过分。

查看数据访问应用程序

块( http://msdn.microsoft.com /netframewo...s/default.aspx

?pull = / library / en-us / dnbda / html / daab-rm.asp),它可能就像这样容易

(C#):


DataSet MyDs = SqlHelper.ExecuteDataSet(MyConnectionString,

CommandType.Text," select name,价值来自mytable");


MyDropDownList.DataSource = MyDs.Tables [0];

MyDropDownList.DataTextField =" name" ;;

MyDropDownList.DataValueField =" value";

MyDropDownList.DataBind();


请注意,使用数据集总是有一些开销,所以你可能想用一个

SqlDataReader来提高性能。


Best r egards,


Marc Hoeppner

NeoGeo

" Leon Shaw" < VN ***** @ msn.com>在消息中写道

news:OX ************** @ tk2msftngp13.phx.gbl ...
Hi Leon,

configuring a typed dataset only gets you halfway there (assuming that''s
what you are doing with the XSD). What you still need to do by hand is to
write some ADO.NET code to establish the connection with the database and to
actually load stuff in your dataset. For example, you could define a
SqlDataAdapter, specify a SELECT... query and use .Fill with your typed
DataSet as parameter (if you use SQL Server). It may be a little overkill to
define a typed dataset and use a DataAdapter only to fill two dropdownlists.
Take a look at the Data Access Application
Blocks(http://msdn.microsoft.com/netframewo...s/default.aspx
?pull=/library/en-us/dnbda/html/daab-rm.asp), it could be as easy as this
(C#):

DataSet MyDs = SqlHelper.ExecuteDataSet( MyConnectionString,
CommandType.Text, "select name, value from mytable" );

MyDropDownList.DataSource = MyDs.Tables[0];
MyDropDownList.DataTextField = "name";
MyDropDownList.DataValueField = "value";
MyDropDownList.DataBind();

Note that using a dataset always has some overhead, so you may want to use a
SqlDataReader for performance.

Best regards,

Marc Hoeppner
NeoGeo
"Leon Shaw" <vn*****@msn.com> wrote in message
news:OX**************@tk2msftngp13.phx.gbl...
配置关系数据后在vs.net中的schema(MyDataSet.xsd),您使用什么代码在Web应用程序中的两个下拉列表控件(
父/子)中显示该数据?
After configuring a relation data schema (MyDataSet.xsd) in vs.net, what
code do you use to display that data within two dropdownlist controls (
parent/child) in an web application?



嗨Leon,


配置一个类型化的数据集只能让你到达那里(假设'

你在用XSD做什么)。你还需要手工做的是

编写一些ADO.NET代码来建立与数据库的连接,并实际加载数据集中的东西。例如,您可以定义一个

SqlDataAdapter,指定一个SELECT ...查询并使用.Fill和您键入的

DataSet作为参数(如果您使用SQL Server)。

定义类型化数据集并仅使用DataAdapter填充两个下拉列表可能有点过分。

查看数据访问应用程序

块( http://msdn.microsoft.com /netframewo...s/default.aspx

?pull = / library / en-us / dnbda / html / daab-rm.asp),它可能就像这样容易

(C#):


DataSet MyDs = SqlHelper.ExecuteDataSet(MyConnectionString,

CommandType.Text," select name,价值来自mytable");


MyDropDownList.DataSource = MyDs.Tables [0];

MyDropDownList.DataTextField =" name" ;;

MyDropDownList.DataValueField =" value";

MyDropDownList.DataBind();


请注意,使用数据集总是有一些开销,所以你可能想用一个

SqlDataReader来提高性能。


Best r egards,


Marc Hoeppner

NeoGeo

" Leon Shaw" < VN ***** @ msn.com>在消息中写道

news:OX ************** @ tk2msftngp13.phx.gbl ...
Hi Leon,

configuring a typed dataset only gets you halfway there (assuming that''s
what you are doing with the XSD). What you still need to do by hand is to
write some ADO.NET code to establish the connection with the database and to
actually load stuff in your dataset. For example, you could define a
SqlDataAdapter, specify a SELECT... query and use .Fill with your typed
DataSet as parameter (if you use SQL Server). It may be a little overkill to
define a typed dataset and use a DataAdapter only to fill two dropdownlists.
Take a look at the Data Access Application
Blocks(http://msdn.microsoft.com/netframewo...s/default.aspx
?pull=/library/en-us/dnbda/html/daab-rm.asp), it could be as easy as this
(C#):

DataSet MyDs = SqlHelper.ExecuteDataSet( MyConnectionString,
CommandType.Text, "select name, value from mytable" );

MyDropDownList.DataSource = MyDs.Tables[0];
MyDropDownList.DataTextField = "name";
MyDropDownList.DataValueField = "value";
MyDropDownList.DataBind();

Note that using a dataset always has some overhead, so you may want to use a
SqlDataReader for performance.

Best regards,

Marc Hoeppner
NeoGeo
"Leon Shaw" <vn*****@msn.com> wrote in message
news:OX**************@tk2msftngp13.phx.gbl...
配置关系数据后在vs.net中的schema(MyDataSet.xsd),您使用什么代码在Web应用程序中的两个下拉列表控件(
父/子)中显示该数据?
After configuring a relation data schema (MyDataSet.xsd) in vs.net, what
code do you use to display that data within two dropdownlist controls (
parent/child) in an web application?



好的我已经调用了adatper.fill和databind命令,但是不是某种类型的

代码,例如Me.DataSet1。 WriteXmlSchema(Me.Request.ApplicationP ath

" DataSet1.xsd"我必须输入以从.xsd文件中获取数据库模式

(我有两个相关表)在我的.xsd文件中,States和School。当你从第一个下拉列表中选择状态时,第二个下拉列表会假设

用正确的方式填充自己那个州的学校。然而,

第一个列表填充了各州,(我将autopostback设置为true,并且

onchange e发泄开火)但页面回发后状态

dropdownlist反复显示System.Data.RelatedView。谢谢

的帮助!


" Marc Hoeppner" <毫安********** @ hotmail.com>在消息中写道

新闻:Ox ************** @ TK2MSFTNGP11.phx.gbl ...
Ok I have call the adatper.fill and databind command, but is''nt some type of
code such as Me.DataSet1.WriteXmlSchema(Me.Request.ApplicationP ath
"DataSet1.xsd" I have to type to get the database schema from the .xsd file
(I have two relate tables in my .xsd file "States" and "School". when you
select a state from the first dropdownlist the second dropdownlist suppose
to populate itself with the correct schools from that state. However, the
first list populate with the states, (I have autopostback set to true, and
the onchange event firing) but after the page postback the state
dropdownlist displays System.Data.RelatedView over and over again. Thanks
for the help!

"Marc Hoeppner" <ma**********@hotmail.com> wrote in message
news:Ox**************@TK2MSFTNGP11.phx.gbl...
Hi Leon,来实际加载数据集中的东西。例如,您可以定义一个SqlDataAdapter,指定一个SELECT ...查询并使用.Fill和您键入的DataSet作为参数(如果您使用SQL Server)。定义类型化数据集并使用DataAdapter仅填充两个
下拉列表可能有点过分
。看看数据访问应用程序

块( http://msdn.microsoft.com/netframewo...s/default.aspx ?pull = / library / en-us / dnbda / html / daab-rm.asp),它可以就像这样简单(C#):

DataSet MyDs = SqlHelper.ExecuteDataSet(MyConnectionString,
CommandType.Text," select name,mytable from mytable);

MyDropDownList.DataSource = MyDs.Tables [0];
MyDropDownList.DataTextField =" name" ;;
MyDropDownList.DataValueField =" value";
MyDropDownList。 DataBind();

请注意,使用数据集总是有一些开销,因此您可能希望使用
a SqlDataReader来提高性能。

祝您好运,
Marc Hoeppner
NeoGeo

" Leon Shaw" < VN ***** @ msn.com>在消息中写道
新闻:OX ************** @tk2msftngp13.phx.gbl ...
Hi Leon,

configuring a typed dataset only gets you halfway there (assuming that''s
what you are doing with the XSD). What you still need to do by hand is to
write some ADO.NET code to establish the connection with the database and to actually load stuff in your dataset. For example, you could define a
SqlDataAdapter, specify a SELECT... query and use .Fill with your typed
DataSet as parameter (if you use SQL Server). It may be a little overkill to define a typed dataset and use a DataAdapter only to fill two dropdownlists. Take a look at the Data Access Application
Blocks(http://msdn.microsoft.com/netframewo...s/default.aspx ?pull=/library/en-us/dnbda/html/daab-rm.asp), it could be as easy as this
(C#):

DataSet MyDs = SqlHelper.ExecuteDataSet( MyConnectionString,
CommandType.Text, "select name, value from mytable" );

MyDropDownList.DataSource = MyDs.Tables[0];
MyDropDownList.DataTextField = "name";
MyDropDownList.DataValueField = "value";
MyDropDownList.DataBind();

Note that using a dataset always has some overhead, so you may want to use a SqlDataReader for performance.

Best regards,

Marc Hoeppner
NeoGeo
"Leon Shaw" <vn*****@msn.com> wrote in message
news:OX**************@tk2msftngp13.phx.gbl...
配置关系数据模式(MyDataSet。 xsd)在vs.net中,您使用什么代码在Web应用程序中的两个下拉列表控件(
父/子)中显示该数据?
After configuring a relation data schema (MyDataSet.xsd) in vs.net, what
code do you use to display that data within two dropdownlist controls (
parent/child) in an web application?




这篇关于XSD VS.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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