Can't implement OleDbTransaction

Posted on 2007-08-12
Last Modified: 2008-02-01
Trying to implement OleDbTransaction Rollback in C#...

I am trying to call the Transaction Rollback and Commit methods to Rollback an OleDb transaction to the database in case of a network interuption or other error.

This is my code:
//ConStr defined in properties
OleDbConnection Conn = new OleDbConnection(ConStr);
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommandBuilder oleDbCb = new OleDbCommandBuilder(da);
//get a compiler error here saying no constructor defined for OleDbTransaction
OleDbTransaction trans = new OleDbTransaction();    
       trans = Conn.BeginTransaction();
       cmd = new OleDbCommand(SQL, Conn);
       da.SelectCommand = cmd;
       da.Update(dataSet1, "Stats");
       MessageBox.Show("Your changes have persisted to the Database!");
   }//end try
         //Close. commit transaction and Dispose called explicitly inside the "finally" block here

When buiold the solution, I get a compiler error saying no constructor defined for OleDbTransaction.
Is my code correct to rollback or commit a transaction?? How do you define a constructor for a method?
Question by:Saxitalis
    LVL 13

    Accepted Solution

    LVL 96

    Assisted Solution

    by:Bob Learned
    No constructor, it gets created from the BeginTransaction call from the connection object.

        OleDbTransaction trans = null;


    Author Comment

    This helped Bob and Hites! Thanks much - sax

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now