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. Visual Basic
  4. Insert data to Database

Insert data to Database

Scheduled Pinned Locked Moved Visual Basic
questiondatabaseoraclesysadminhelp
4 Posts 2 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.
  • L Offline
    L Offline
    lucdt
    wrote on last edited by
    #1

    HI all ! I have a problem. I buil a procedure which insert data to Oracle Database. In the procedure I call twice ( 2 times) the StoredProcedure. Both these StoredProcedure aslo using common a Transaction. The first done well but immediately my application was pending ( may be the broken network,...) and I have to restart my application. But in Oracle Database the data have inserted. Pls, tell me why ? and How can I resolve it. Althought a Transaction in my application didn't commit; Thank alot

    D 1 Reply Last reply
    0
    • L lucdt

      HI all ! I have a problem. I buil a procedure which insert data to Oracle Database. In the procedure I call twice ( 2 times) the StoredProcedure. Both these StoredProcedure aslo using common a Transaction. The first done well but immediately my application was pending ( may be the broken network,...) and I have to restart my application. But in Oracle Database the data have inserted. Pls, tell me why ? and How can I resolve it. Althought a Transaction in my application didn't commit; Thank alot

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Without seeing your code, it's impossible to tell you how to fix it. But, in general, you should put the update code in stored procedures in the database and let it worry about the transaction details. Dave Kreskowiak Microsoft MVP - Visual Basic

      L 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Without seeing your code, it's impossible to tell you how to fix it. But, in general, you should put the update code in stored procedures in the database and let it worry about the transaction details. Dave Kreskowiak Microsoft MVP - Visual Basic

        L Offline
        L Offline
        lucdt
        wrote on last edited by
        #3

        Hi! My code is here ! pls, hekp me ===================== g_trans = g_Conn.BeginTransaction Me.g_cmd = New OracleClient.OracleCommand // The first. I hate to insert the header of bill into BillHeader Table With g_cmd .Connection = g_Conn .Transaction() = g_trans .CommandType = CommandType.StoredProcedure .CommandText = "PKG_NHAP_TBI.SpInsert_TDPhieuNhap" .Parameters.Clear() .Parameters.Add("v_soct", soCT).Direction = ParameterDirection.Input .......... .ExecuteNonQuery() End With // Then, I have to insert detail each Item into Items Table With g_cmd .Connection = g_Conn .Transaction() = g_trans .CommandType = CommandType.StoredProcedure .CommandText = "PKG_NHAP_TBI.SpInsert_CTPhieuNhap" .Parameters.Clear() .Parameters.Add("v_soct", soCT).Direction = ParameterDirection.Input ............... .ExecuteNonQuery() End With ========= When both procedures successful, I must commit the Transaction ( g_trans.Commit()). But If have some problem, I have to rollback all (g_trans.Rollback())

        L 1 Reply Last reply
        0
        • L lucdt

          Hi! My code is here ! pls, hekp me ===================== g_trans = g_Conn.BeginTransaction Me.g_cmd = New OracleClient.OracleCommand // The first. I hate to insert the header of bill into BillHeader Table With g_cmd .Connection = g_Conn .Transaction() = g_trans .CommandType = CommandType.StoredProcedure .CommandText = "PKG_NHAP_TBI.SpInsert_TDPhieuNhap" .Parameters.Clear() .Parameters.Add("v_soct", soCT).Direction = ParameterDirection.Input .......... .ExecuteNonQuery() End With // Then, I have to insert detail each Item into Items Table With g_cmd .Connection = g_Conn .Transaction() = g_trans .CommandType = CommandType.StoredProcedure .CommandText = "PKG_NHAP_TBI.SpInsert_CTPhieuNhap" .Parameters.Clear() .Parameters.Add("v_soct", soCT).Direction = ParameterDirection.Input ............... .ExecuteNonQuery() End With ========= When both procedures successful, I must commit the Transaction ( g_trans.Commit()). But If have some problem, I have to rollback all (g_trans.Rollback())

          L Offline
          L Offline
          lucdt
          wrote on last edited by
          #4

          Hi! My code is here ! pls, help me. Thank alot ===================== // Then, I have to insert detail each Item into Items Table For i .... With g_cmd .Connection = g_Conn .Transaction() = g_trans .CommandType = CommandType.StoredProcedure .CommandText = "PKG_NHAP_TBI.SpInsert_CTPhieuNhap" .Parameters.Clear() .Parameters.Add("v_soct", soCT).Direction = ParameterDirection.Input ............... .ExecuteNonQuery() End With Next ========= When both procedures successful, I must commit the Transaction ( g_trans.Commit()). But If have some problem, I have to rollback all (g_trans.Rollback())

          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