Creating Schemas and DataSets from Existing Data

only for RuBoard

Creating Schemas and DataSets from Existing Data

XML Designer enables you to quickly create a schema based on an existing data source. This helps you when an existing source contains the desired structure for your application, and you want to use this structure without having to define each element.

Start by adding a DataSet to the project by using the Add New Item option from the Solutions Explorer (see Figure 4.28).

Figure 4.28. The Add New Item option.
graphics/04fig28.gif

This action adds a new, blank schema file ( .xsd ) and a corresponding DataSet class file, with the same name as that of the schema file, to your project. So, if you name the DataSet file CustomerOrders , you'll have both CustomerOrders.xsd and CustomerOrders.cs added to the project.

In the Server Explorer, if you do not already have the connection to the required existing data source, you can create the connection by using the Data Link Properties dialog box. This dialog box is invoked when you choose Connect to Database from the Tools menu with the Server Explorer open . Figure 4.29 shows how you can configure your connection to the desired provider on an SQL server.

Figure 4.29. The Data Link Properties from the Server Explorer.
graphics/04fig29.gif

After you have the connection, you can see the required data source by expanding the Data Connections node and then expanding the node for the specific connection. In the Connection node, expand the node for Tables, Stored Procedures, or Views, depending on from what you want to infer the schema structure. Select the item and drag it on the XML Designer surface. Figure 4.30 shows the Schema view of the XML Designer with the two tables, Customers and Orders , dragged from the Northwind database.

Figure 4.30. The Schema view of the XML Designer with Customers and Orders dragged from the Northwind database.
graphics/04fig30.gif

If you want to build the schema based on specific columns, you can expand the source node and select only the specific columns that you want before you drag it onto the designer (see Figure 4.31).

Figure 4.31. Selecting the specific columns from a table.
graphics/04fig31.gif

Now you can add a Relation object to the schema if you want to establish a relationship between the multiple tables you have added.

only for RuBoard


XML and ASP. NET
XML and ASP.NET
ISBN: B000H2MXOM
EAN: N/A
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net