thespot4sap.com independent sap information
 

get SAP Access - pay monthly

SAP Tutorials    Online SAP Training    SAP CBT's    SAP Forums    SAP Articles    SAP Jobs    SAP Resumes
  SAP Access    SAP Blogs    SAP Books     Links     SAP Vendor Directory     Submit Content    Search
Previous posts in Other ERP
Page 5038 of 5660

SAMPLE:How to use system.transaction to intiate transaction with oracle

Blogger : MSDN Blogs
All posts : All posts by MSDN Blogs
Category : Other ERP
Blogged date : 2006 Mar 14

//copy following program into console app and replace connection string and query string

using System;
using System.Collections.Generic;
using System.Text;
using System.Transactions;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;

namespace TransClient
{
    class Program
    {
      
       static void Main(string[] args)
       {
           ConnectToOracle();
           Console.WriteLine("Press any key to quit");
           Console.ReadKey();

       }
       
        //Try to connect to oracle database

        public static void ConnectToOracle()
        {
       
      
   /*
          VERSION: windows xp,sp2/.NET 2.0/oracle client 9i/Microsoft oledb provider/oracle oledb provider
         
NOTE:

            incase if data provider can't understand systx,provide COM+/ES context
              TransactionOptions to = new TransactionOptions();
               using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required,to,EnterpriseServicesInteropOption.Full))

        */         
        
            //using Microsoft oledb provider

            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
            {

                OleDbConnection conn = new OleDbConnection();
    conn.ConnectionString = "Provider=MSDAORA.1;User ID=XXX;password=XXX;Data Source=oracleservername;Persist Security 
    Info=False";
                conn.Open();

          OleDbCommand cmd = new OleDbCommand("insert into XXX values('5')", conn);
                cmd.ExecuteNonQuery
                ts.Complete();
            }
      
            //using oracle oledb provider

            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
            {

                OleDbConnection conn = new OleDbConnection();
                conn.ConnectionString = "Provider=ORAOLEDB.ORACLE.1;User ID=XXX;password=XXX;Data Source=oracleservername;Persist
                Security Info=False";
                conn.Open();
                OleDbCommand cmd = new OleDbCommand("insert into XXX values('5')", conn);
                cmd.ExecuteNonQuery();
                ts.Complete();
            }

           

        }

      
    }
}


Read comments or post a reply to : SAMPLE:How to use system.transaction to intiate transaction with oracle
Page 5038 of 5660

Newest posts
New Page 1

 

 

About Us   Contact Us   Privacy   Disclaimer   Feedback   Email Discussion   Newsletter  

Copyright © - Independent SAP Information
Learn XML, Guesthouses and B&B's