• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

WCF Transaction Example

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”;
}
}
}

Summary
Review Date
Reviewed Item
WCF Transaction Example
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on WCF Transaction Example"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.