Chapter2: Use a strong data set and tableadapter

Source: Internet
Author: User

P61-2.9

If you addCodeTo access the connection attribute, You can dynamically set or modify the data connection object. There are two ways to achieve this:

1. In a separate helper class;

2. In the partial class file that defines your own code written for the tableadapter class.

P63

Q: When defining a class, if you determine its namespace?

P64-2.10

Use Database transactions directly in ADO. Net:

1. Open a connection;

2. Call the begintansaction method on the connection;

3. Assign the returned transaction object to each command object. These command objects are executed as part of the transaction;

4. Call the commit method of the transaction object after the transaction operation is completed.

Summary:

1. If you can understand the data architecture during design, you should use a strong data set;

2. Put the data access code (including strong datasets) into a separate class library project, instead of forming a decoupling layered structure in the windowsforms project;

3. Drag and Drop tables, stored procedures, or views from Server Explorer to datasetdesigner to generate strong table classes and corresponding tableadapters. These tableadapters can be used to obtain and update data in a strongly typed manner from a data table. You can add a query to the tableadapter through the "add query" shortcut menu of the designer;

4. you can use the partial class to extend the partial class, such as dataset, tableadapter, table, and row, to add custom functions to these classes, and even if you need to regenerate the dataset definition, these extended functions will not be damaged.

 

 

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.