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 8561365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:29:12+00:00 2026-06-11T16:29:12+00:00

after successfully saving a transaction using my code…I edit the transaction and then save…then

  • 0

after successfully saving a transaction using my code…I edit the transaction and then save…then i come up with this error message:

ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized.

here is my code:

Try
  sqlTrans = sqlCon_.BeginTransaction(IsolationLevel.RepeatableRead)
  sSQLAdapter_.UpdateBatchSize = 30
  sCommand_ = DirectCast(sSQLAdapter_.SelectCommand, SqlCommand)
  sCommand_.Connection = sqlCon_ 
  sCommand_.Transaction = sqlTrans 
  sSQLAdapter.SelectCommand.Transaction = sqlTrans

  sSQLAdapter_.Update(sDataSet.Tables(0))

  sqlTrans.Commit()
  sqlCon_.Close()

Catch ex As Exception
  sqlTrans.Rollback()
Finally
   sSQLAdapter.SelectCommand.Connection.Close()
   sSQLAdapter.SelectCommand.Connection = Nothing
   sSQLAdapter.SelectCommand.Transaction = Nothing
   sSQLAdapter.SelectCommand.CommandText = ""
   sSQLAdapter.SelectCommand.Dispose()

   sqlTrans.Dispose()
   sqlCon_.Close()
   sqlCon_.Dispose()
End Try
  • 1 1 Answer
  • 0 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-06-11T16:29:13+00:00Added an answer on June 11, 2026 at 4:29 pm

    You need to set Transaction object reference for InsertCommand, UpdateCommand and DeleteCommand object of SqlDataAdapter because you’re calling Update method.

    MSDN reference document – Using Transactions with a DataAdapter

    Sample :

    Using Cn As New SqlConnection(CnStr)
     Cn.Open()
     Using Trans As SqlTransaction = Cn.BeginTransaction
       Dim Adp As New SqlDataAdapter(selectQuery, Cn)
       Adp.SelectCommand.Transaction = Trans
    
       Dim cmb As New SqlCommandBuilder(Adp)
       Adp.DeleteCommand = cmb.GetDeleteCommand()
       Adp.InsertCommand = cmb.GetInsertCommand()
       Adp.UpdateCommand = cmb.GetUpdateCommand()
    
       Adp.InsertCommand.Transaction = Trans
       Adp.DeleteCommand.Transaction = Trans
       Adp.UpdateCommand.Transaction = Trans
    
       Dim dt As New DataTable
       Adp.Fill(dt)
       /* ------------- 
    
        Perform insert/delete/update on DataSet or DataTable 
        -------------- */ 
       Adp.Update(dt)
       Trans.Commit()
      End Using
     Cn.Close()
    End Using
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to show a message Successfully added after saving the record to the
After successfully opening Pop3Folder , and retrieving messages from it, I then sometimes get
I'm using NetDataContractSerializer . After successfully deserializing an object, is there a way to
I am using Struts application while running welcome page is run successfully after that
After logged in successfully, Yii does not executing any page. Showing an error: Error
I have been trying to post using RestKit after I have successfully used it
After following the advice in this question successfully, I added a couple additional lines
I have a UserProfile entity which I need to save. after saving the entity
i am displaying the one confirm box after saving the values like this showalert(Quote
After successfully acquiring an oauth_token for a user, I am able to get successful

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.