Detailed introduction of Asp.netweb related services

Source: Internet
Author: User

After a long time to learn asp.netweb, so share with you, read this article you certainly have a lot of harvest, hope this article can teach you more things. When you learn asp.netweb , you may experience related problems, and here's how to solve the asp.netweb problem.

The structure is divided into three levels: the presentation layer, the business layer, and the data layer. Data tier: Represents the physical database. Business layer: Responsible for data transfer between the layer and presentation layer. Presentation layer: The client of an application that accesses the database through the business layer.

The presentation layer operates on local data that resides in memory and is implemented through the update methods provided by the business layer when database data needs to be updated. This can greatly improve the performance of your application, and when it is entirely up to you to update your data, you improve your programming flexibility.

Instance:

Here's a concrete example to see how to create a three-tier application with vb.net.

Database: We chose SQL Server's Northwind database. Business layer: We create a webservice as the middle tier. (Need to install IIS Service) Presentation layer:asp.netweb We write a windowsform first step: Create WebService.

The specific steps are as follows:

1. Create a new project, select asp.netweb service, named: "Webservicefor Business Layer".

2. Add two SqlDataAdapter, one for Customer_da, pointing to the Customers table of the Northwind database,asp.netweb Another to Order_da, to the Orders table for the Northwind database.

3. Then generate a TypedDataSet (choose "Data" menu, "Generate DataSet"), named: Super_ds.

4. The database connection is complete, and next we will consider the communication between it and the presentation layer, where we define two methods. One is: Get_dataset, which returns a Super_ds type DataSet and another: Update_dataset, which is responsible for updating the database data, the method code is as follows:

 
 
  1. ImportsSystem.Web.Services
  2. PublicClassService1
  3. InheritsSystem.Web.Services.WebService
  4. ' Webservicesdesignergeneratedcode ...
  5. <webmethod ()>publicfunctionget_dataset () assuper_ds
  6. Customer_da. Fill (SUPER_DS1. Customers)
  7. Order_da. Fill (SUPER_DS1. Orders)
  8. Returnsuper_ds1
  9. Endfunction
  10. <webmethod ()>publicsubupdate_dataset ()
  11. Super_ds1. AcceptChanges ()
  12. Endsub
  13. Webserviceexample
  14. Thehelloworld () Exampleservicereturnsthestringhelloworld.
  15. Tobuild,uncommentthefollowinglinesthensaveandbuildtheproject.
  16. Totestthiswebservice,ensurethatthe.asmxfileisthestartpage
  17. AndpressF5.
  18. <webmethod ()>publicfunctionhelloworld () asstring
  19. Elloworld="HelloWorld"
  20. Endfunction
  21. Endclass


Related Article

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.