Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the ADO.NET XML architecture

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use the ADO.NET XML architecture". The content in the article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use the ADO.NET XML architecture".

Given an ADO.NET XML schema that conforms to the ADO.NET XML Schema definition language (XSD) standard, you can generate strongly typed DataSet using the XSD.exe tools provided with the Windows Software Development Kit (SDK). The following code shows the syntax for generating DataSet using this tool.

Xsd.exe / d / l:CS XSDSchemaFileName.xsd / eld / n:XSDSchema.Namespace

In this syntax, the / d instruction instructs the tool to generate DataSet,/l: tell the tool which language to use (such as C # or Visual Basic .NET). The optional / eld directive specifies that you can use LINQ to DataSet to query the generated DataSet. You can use this option when the / d option is also specified. For more information, see querying typed datasets. The optional / n: directive instructs the tool to also generate a namespace for the DataSet named XSDSchema.Namespace. The output of the command is XSDSchemaFileName.cs, which can be compiled and used in ADO.NET applications. The generated code can be compiled into libraries or modules.

The following code shows the syntax for accessing the namespace passed to XSD.exe in the ADO.NET application.

Imports XSDSchema.Namespace

The following code example uses a typed DataSet named CustomerDataSet to load a list of customers in the Northwind database. When the data is loaded using the Fill method, the example loops through each customer in the Customers table using a typed CustomersRow (DataRow) object. It provides direct access to CustomerID columns rather than through DataColumnCollection.

Dim customers As CustomerDataSet= New CustomerDataSet () Dim adapter As SqlDataAdapter New SqlDataAdapter (_ "SELECT * FROM dbo.Customers;", _ "Data Source= (local); Integrated" & _ "Security=SSPI;Initial Catalog=Northwind") adapter.Fill (customers, "Customers") Dim customerRow As CustomerDataSet.CustomersRow For Each customerRow In customers.Customers Console.WriteLine (customerRow.CustomerID) Next

The following is the ADO.NET XML schema used for this example.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report