C # How to use DataSet + dataAdapter to operate background databases

Source: Internet
Author: User

The following code demonstrates how to use DataSet + dataAdapter to operate the background database and provides transaction processing.

Code
 1 using System;
2 using System. Web. Services;
3 using System. Data;
4 using System. Data. OleDb;
5
6 namespace TransactionTest
7 {
8 /// <summary>
9 // Service1 Summary
10 /// </summary>
11 [WebService (Namespace = "http://tempuri.org/")]
12 [WebServiceBinding (ConformsTo = WsiProfiles. BasicProfile1_1)]
13 [System. ComponentModel. ToolboxItem (false)]
14 // to allow ASP. net ajax to call this Web service from a script, cancel the comments to the downstream.
15 // [System. Web. Script. Services. ScriptService]
16 public class TransWsTest: System. Web. Services. WebService
17 {
18 // Private attributes
19 private OleDbConnection _ DBConn;
20 private OleDbTransaction _ DBTrans;
21
22 [WebMethod]
23 public string HelloWorld ()
24 {
25 _ DBConn. Close ();
26 return "Hello World ";
27}
28
29 [WebMethod]
30 public string TransTest_Insert ()
31 {
32 try
33 {
34
35 InsertData ("Ma Kan", "R & D department ");
36 InsertData ("Li Wei", "R & D department ");
37 // InsertData ("Ma Kan", "R & D department ");
38
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.