How to create database Web Services

Source: Internet
Author: User
Tags create database how to create database
The most obvious use of XML Web Services is universal data access. With it, you can access your company's database by many clients on the Internet, or dynamically import it to a third-party Web site, you can even allow your business partner's Web Services to query. The following explains how to create a simple Web service to display your database content to Internet Explorer, third-party Web Services, and custom C # and VB. NET clients.
Partners, customers, and employees have a wealth of experience in using data designed for multiple devices. No matter how your current database is organized, to ensure universality, web Services returns XML data to the client. For example, if a logistics company (your partner) wants to deliver your goods to your customers, when the delivery arrives at the customer's door, his PDA displays the information about the change of the departure address. At this time, the freight car easily delivers the information to other places, because your customer has changed his address in the database, this change is automatically updated in your partner's system.
Next, write your own ASP. NET database Web Services. First, check your database to see if it can easily output data in XML format and whether ADO. NET can be read and dynamically converted. In some cases, you may need to convert the current database to meet this requirement. If your database access code becomes complex and affects scalability, we recommend that you convert the database.
For simplicity, we assume that the database in the example has only one "Products" table. Of course, your database may have many tables, or your Web Services may need to access more than one database.
Now we can start writing code. Open Visual Studio. NET and create a C # ASP. NET Web Services project under the DataBaseWebService directory, as shown in the figure:
Right-click Service1.asmx and rename Service1.asmx to DataBaseWebService. asmx. This file will contain WebMethods that obtain data from the database. Then, right-click and select "View code" to switch to the code view and change it to the DataBaseWebService class and constructor name.
First, reference the. NET class library: using System. Data. SqlClient;

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.