Browse multiple related tables in the ADO. Net dataset (2)

Source: Internet
Author: User
Browse multiple related tables in the ADO. Net dataset (2)
Author: MicrosoftWww.aspcool.comTime: 13:51:08 views:9053

Create an application
This section describes how to start this drill. The subsequent steps will create data connections, data adapters, datasets that contain relevant tables, and several controls for selecting and displaying data.

Create a new Windows Application

From the File menu, point to new and select project ). The new project dialog box is displayed.
In the project types (project type) pane, select Visual Basic projects (Visual Basic Project) or Visual C # projects (Visual C # project) based on the programming language you need ).
In the templates (Template) pane, select windows application, name it datarelationexample, and click OK ).
The datarelationexample project will be added to Solution Explorer.

Connect to database
This connection allows you to communicate with data sources in the integrated development environment (IDE) of Visual Studio.

Connect to the Rose Sample Database in Server Explorer

In Server Explorer (server resource manager), establish a data connection to the sample database in the Rose text.
Expand the Cairo text data connection in Server Explorer until you can see all the tables.
Create a data adapter and Connection
This step creates a connection and data adapter for connecting and exchanging data between an application and a data source.

Create a data adapter and Connection

Drag the customer table from Server Explorer (server resource manager) to the form. The connection and data adapter are displayed in the components column.
Select connection and set the name attribute to dcnorthwind.
Select the data adapter and set the name attribute to dacustomers.
Drag the order table from Server Explorer (server resource manager) to the form. The second data adapter is displayed in the component column.
Select a new data adapter and set the name attribute to daorders.
Generate a dataset
Use the data adapter added to the form to generate a dataset containing the customer table and order table.

Generate a dataset that will contain the relevant data table

Select generate dataset from the data menu ). The generate dataset dialog box is displayed.
Tip: move the cursor over the form to use the data menu.
Click new and name the dataset dsnorthwind.
Select the customer table and order table.
Select the add this dataset to the designer check box and click OK ).
A file named dsnorthwind. XSD is added to the Solution Explorer project, and an instance of the dataset is displayed in the component bar.

Create Link
The relationship between tables in the dataset cannot be automatically created when a dataset is generated. You can create links through programming or using XML designer. This document uses XML designer ).

Create the relationship between the customer table and the order table

In Solution Explorer, double-click the dsnorthwind. XSD file. The file is opened in XML designer.
Drag the relationship from the XML schema tab on the toolbar to the order table.
In the edit relation dialog box, set the following attributes:

Element settings
Name customersorders
Parent MERs
Child orders
Key Fields customerid
Foreign key fields customerid


Click OK to create a link and close the dialog box.
From the File menu, select Save all to save the project.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.