Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ADO.Net 2.0 Transaction

ADO.Net 2.0 Transaction

Scheduled Pinned Locked Moved C#
csharptestingbeta-testinghelpannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Agyeman
    wrote on last edited by
    #1

    hi the code below throws this exception "ExecuteReader 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." on the update statement in the try catch block. Please help. DatabaseDataSet.PersonnalInfoDataTable ds = new DatabaseDataSet.PersonnalInfoDataTable(); DatabaseDataSetTableAdapters.PersonnalInfoTableAdapter adapter = new Testing.DatabaseDataSetTableAdapters.PersonnalInfoTableAdapter(); adapter.Fill(ds); DatabaseDataSet.PersonnalInfoRow newrow = ds.NewPersonnalInfoRow(); newrow["firstname"] = this.textBoxFirstName.Text; newrow["lastname"] = this.textBoxLastName.Text; newrow["telephone"] = this.textBoxTelephone.Text; ds.AddPersonnalInfoRow(newrow); adapter.Connection.Open(); SqlTransaction myTrans= adapter.Connection.BeginTransaction(); try { adapter.Update(ds); myTrans.Commit(); ds.AcceptChanges(); } catch(Exception l) { myTrans.Rollback(); ds.RejectChanges(); } adapter.Connection.Close();

    Nana

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups