Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 758925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:32:12+00:00 2026-05-14T15:32:12+00:00

I have a DataSet that I have added to my project where I can

  • 0

I have a DataSet that I have added to my project where I can Insert and Add records using the Add Query function in Visual Studio 2010, however I want to add transactions to this, I have found a few examples but cannot seem to find one that works with these.

I know I need to use the SQLClient.SQLTransaction Class somehow. I used the Add New Data Source Wizard and added the Tables/View/Functions I need, I just need an example using this process such as How to get the DataConnection my DataSet has used. Assuming all options have been set in the wizard and I am only using the pre-defined adapters and options asked for in this wizard, how to I add the Transaction logic to my Database.

For example I have a DataSet called ProductDataSet with the XSD created for this, I have then added my Stock table as a Datasource and Added an AddStock method with a wizard, this also if a new item calls an AddItem method, if either of these fails I want to rollback the AddItem and AddStock in this case.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:32:13+00:00Added an answer on May 14, 2026 at 3:32 pm

    In this example, I have a dataset called “dsMain” and a few direct queries in a “QueriesTableAdapter”. I extend the partial class for the TableAdapter with a function that will create a transaction based on the first (0) connection and then apply it to every connection in the table adapter.

    Namespace dsMainTableAdapters
        Partial Public Class QueriesTableAdapter
            Public Function CreateTransaction() As Data.IDbTransaction   
                Dim oConnection = Me.CommandCollection(0).Connection
                oConnection.Open()
    
                Dim oTrans = oConnection.BeginTransaction()
    
                For Each cmd In Me.CommandCollection
                    cmd.Connection = oConnection
                    cmd.Transaction = oTrans
                Next
    
                Return oTrans
            End Function
        End Class
    End Namespace
    

    You begin the transaction by calling the new function

    Dim qa As New dsMainTableAdapters.QueriesTableAdapter
    Dim oTrans = qa.CreateTransaction()
    

    Then you can call TableAdapter queries within your transaction

    qa.Query1
    qa.Query2
    

    When you are done with your queries you commit the transaction

    oTrans.Commit()
    

    You can do the same thing for any TableAdapter that was created for your datasets.
    If you have multiple TableAdapters that need to use the same transaction, then in addition to a “CreateTransaction” you should make a “SetTransaction” and have the Transaction be a parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've added a web service into my project in Visual Studio but I can't
I have a datagrid that is filled with a dataset from an SQL query.
I have several controls in a winform application that I added databindings to using
I have an ajax request that looks like this, $(#frmProducts).submit(function(){ var dataSet = $(#frmProducts).serialize();
I am starting a new project using WCF so that I can use jQuery
I have a dataset that i am trying to set the default value as
I have a dataset that returns questions and answers from the database, each answer
I have a large dataset that load in with a fill method on page
I have a large dataset that I am dealing with in Python. It is
I have a (dense) dataset that consist of 5 groups, so my data.frame looks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.