WCF Transaction Example

Ratings:
(4)
Views:312
Banner-Img
  • Share this blog:

Create a client application to consume the 3 services created by the transactions

Create a new web site with the name  WCF traction client à Design the page à add references 3 WCF services created early in this program

  1. For WCF customer service with reference name as ‘SFC’ (service reference for customer)
  2. For WCF merchant service with reference name as “SRM”
  3. To WCF transaction service with reference  name as “SRT” add reference to “System

Transactions” Namespace 11 write the following code using system data sqlclient; using system Transactions; using SRC; using SRM; using SRT; sqlconnection con= new sqlconnection (“---“) ; protected void btnsubmit_click(----) { Screenshot_78

  1. strings = “select c balance from customer where c ID=’ “ + extcid.text + “ ‘ “ ; Open (); sqlcommand cmd = new sql command (s, con); sqldata reader Dr = cmd. Execute reader (); Dr. Read (); double cbal = convert . to Double ( Dr [0]); cbal = cbal – convert. To Double (txtamt.text);

Con.close(); s= “select cbalance from merchant where MID = ‘ “cmd = new sql command (s, con); con opend(); Dr = cmd. Execute reader(); DR. Read (); double M Bal = convert. Tobouble (DR[0]); MBal = MBal + convert . to double (txt Tamt.text); con.close(); if (<bal<0) lbl display text ‘balance is not sufficient, transaction cannot be performed”; else { using (transaction scope TS = new transaction scope option. Required) { try { customer client objc = new customer clinet (); Merchant client objM = new merchant client (); Transaction client objT = new Transaction client (); objc update customer (txtcId. Text, cbal); objM. Insert transaction ((txt Tid – text, text Cid. Text, txt Mid. Text, datatime. Now .date, convert. To bouble / txt tamt. Text), cbal, mbal); T.S.complete(); lbldisplay.text = “Transaction successful”; } catch { TS dispose (); lbldisplay.text =”Transaction Rooled back”; } } }

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox