FileAdapter.ChangeCurrent Method

Updates the current database file record with the contents of the specified AdgDataSet.ActiveRow property.

        [C#]
public void ChangeCurrent(
   AdgDataSet ds
};
      
        [Visual Basic] 
Public Sub ChangeCurrent( _
   ByVal ds As AdgDataSet _
)
      
        [Visual RPG]
   BegSub ChangeCurrent Access(*Public)
   DclSrParm ds Type(AdgDataSet)
      
Parameters
ds
The DataSet object (ASNA.DataGate.Client.AdgDataSet) used to update the database file record.
Exceptions
Exception Type Condition

NullReferenceException

FileAdapter open method has not been called (file is not open).

dgException

See table below.

ASNA.DataGate.Common.dgException is thrown to signal normal procedural conditions, in addition to error conditions. The following table summarizes these conditions, and the corresponding value of the dgException.Error property.


Value of
dgException.Error
Condition

dgEaNOTUPD

The file was not opened for update. To use ChangeCurrent, the AccessMode property must be set to a value which includes the AccessMode.Change flag prior to opening the file.

dgEsAS400ERROR

The database server encountered a system error. Details may be available via the SystemError and Text fields of dgException.

dgEaNOCURR

There is not a current record associated with the file. If the file is open for "network blocking", the current record position on the server is unknown.

dgEaBUSYREC

Record is in use or locked by another process. You cannot access the requested record because it is being used by another database process. Certain DataGate providers may provide further details of the conflicting process in the Message and Text members of dgException.

Remarks

ChangeCurrent updates the contents of the current record of an open file. The current record is usually the record most recently accessed (by read or seek method). On database providers such as the IBM i, the record must be locked for update and upon completion of ChangeCurrent, the record is unlocked. Locking the record for update is performed by reading or seeking to the record without specifying a "no lock" option.

Examples
        
          [C#]
        
  AdgConnection db = new AdgConnection("*Public/DG NET Local");
  FileAdapter dbFile = new FileAdapter(db, "*Libl/CMASTNEWL1", "CMMASTERL1");
  dbFile.AccessMode = AccessMode.Read | AccessMode.Change;

  AdgDataSet myDS = null;
  try
  {
      dbFile.OpenNewAdgDataSet(out myDS);
  }
  catch(dgException dgEx)
  {
      MessageBox.Show("Error opening file! " + dgEx.Message, "Error");
      //Exit procedure or end application here.
  }
  /* We read the first record of the file... */
  dbFile.ReadSequential(myDS, ReadSequentialMode.First, LockRequest.Default);
  myDS.SetActive(myDS.GetFormatName(0), 0); 
  /* ...and make the customer name all caps. */
  string CustName = System.Convert.ToString(myDS.ActiveRow["CMName"]);
  CustName = CustName.ToUpper();
  myDS.ActiveRow["CMName"] = CustName;
  try
  {
      /* Here we update the record. */
      dbFile.ChangeCurrent(myDS);
  }
  catch (dgException dgEx)
  {
      MessageBox.Show("Error updating record: " + dgEx.Message, "Error.");
      // Exit routine or take alternative action here.
      test.Actual = "Catch occured.";
  }

  dbFile.Close();
  db.Close();
        
          [Visual Basic]
        
  Dim db As New AdgConnection("*Public/DG NET Local")
  Dim dbFile As New FileAdapter(db, "*Libl/CMASTNEWL1", "CMMASTERL1")
  dbFile.AccessMode = AccessMode.Read Or AccessMode.Change

  Dim myDS As AdgDataSet = Nothing
  Try
      dbFile.OpenNewAdgDataSet(myDS)
  Catch dgEx As dgException
      MsgBox("Error opening file! " + dgEx.Message, MsgBoxStyle.OKOnly, "Error")
      'Exit procedure or end application here.
  End Try
  ' We read the first record of the file... 
  dbFile.ReadSequential(myDS, ReadSequentialMode.First, LockRequest.Default)
  myDS.SetActive(myDS.GetFormatName(0), 0)
  ' ...and make the customer name all caps. 
  Dim CustName As String
  CustName = System.Convert.ToString(myDS.ActiveRow.Item("CMName"))
  CustName = CustName.ToUpper()
  myDS.ActiveRow.Item("CMName") = CustName
  Try
      ' Here we update the record. 
      dbFile.ChangeCurrent(myDS)
  Catch dgEx As dgException
      MsgBox("Error updating record: " + dgEx.Message, MsgBoxStyle.OKOnly, "Error")
      ' Exit routine or take alternative action here.
  End Try
Requirements

Namespace: ASNA.DataGate.Client

Assembly: ASNA DataGate Client

Platforms: Windows Server 2008 R2, Windows Server 2012, Windows 7, Windows 8 Pro, Windows 8.1 Pro, Windows 10

See Also