1 Reply Latest reply: Sep 18, 2012 1:06 PM by 944846 RSS

    OracleCommandBuilder not optimistic mode

    944846
      Hi,
      i'm using odp 11.2.0.4

      i've an oracle table with a primary key
      in my code i do the below operation.

      sql = "select * from mytable"
      odaInstall = new OracleDataAdapter(sql, DbRepos.Connection);
      dtInstall = new DataTable("mytable");
      odaInstall.Fill(dtInstall);
      OracleCommandBuilder ocb = new OracleCommandBuilder(odaInstall);
      odaInstall.UpdateCommand = ocb.GetUpdateCommand();
      // change my record
      odaInstall .update();




      with the above code i created an update command for an optimistic case, but i don't want this.
      I need an oracle update command that in the where condition uses only the primary key.

      is there a way to do this automatically?
        • 1. OracleCommandBuilder not optimistic mode
          Lannie Liberty
          Imports System.Xml.Linq.XElement

          Public Shared Sub updateUnitsActiveFlag(ByVal decCustomerSeq As Decimal)
          ' Update the UNITS.ACTIVE_FLAG on Customer set to Inactive'
          Dim connectionString As String = ConfigurationManager.ConnectionStrings("OraConnStr").ConnectionString
          Try
          Dim SQL =
          <SQL>
          UPDATE {YOURSCHEMANAME}.UNITS
          SET ACTIVE_FLAG = 'Inactive',
          SEND_CONTRACT_FLAG = 'Do not send'
          WHERE CUSTOMER_SEQ = :CUSTOMER_SEQ
          </SQL>
          Using conn As New OracleConnection(connectionString)
          Using cmd As New OracleCommand(SQL.Value, conn)
          cmd.Parameters.Clear()
          cmd.Parameters.Add("CUSTOMER_SEQ", OracleDbType.Decimal, decCustomerSeq, ParameterDirection.Input)
          conn.Open()
          cmd.ExecuteNonQuery()
          End Using
          End Using
          Catch ex As Exception
          ' your exception handling here
          End Try
          End Sub