dotConnect for SQLite Documentation
Devart.Common Namespace / DbDataTable Class / UpdatingKeyFields Property
Example

In This Topic
    UpdatingKeyFields Property (DbDataTable)
    In This Topic
    Gets or sets string containing list of key field names separated by semicolon. They are used to generate update commands.
    Syntax
    'Declaration
     
    Public Property UpdatingKeyFields As String
    public string UpdatingKeyFields {get; set;}

    Property Value

    The string containing list of key field names separated by semicolon.
    Example
    The following example demonstrates how to use the UpdatingKeyFields property.
    static void UseDataTable(DbDataTable myDataTable, DbConnection myConnection) {
    
      myDataTable.Connection = myConnection;
      myDataTable.SelectCommand = myConnection.CreateCommand();
      myDataTable.SelectCommand.CommandText = "SELECT e.EMPNO, e.ENAME, e.JOB, d.DNAME FROM Dept d, Emp e where d.Deptno = e.Deptno";
    
      myDataTable.FetchAll = true;
      myDataTable.CachedUpdates = false;
      myDataTable.UpdatingTable = "Emp";
      myDataTable.UpdatingKeyFields = "EMPNO";
      myDataTable.UpdatingFields = "EMPNO;ENAME;JOB";
    
      myDataTable.Open();
    
      DataRow row = myDataTable.Rows[0];
      row[myDataTable.Columns["ENAME"]] = "John Smith";
    
      myDataTable.Update();
      myDataTable.Close();
    }
    Private Shared Sub UseDataTable(ByVal myDataTable As DbDataTable, ByVal myConnection As DbConnection)
      myDataTable.Connection = myConnection
      myDataTable.SelectCommand = myConnection.CreateCommand
      myDataTable.SelectCommand.CommandText = "SELECT e.EMPNO, e.ENAME, e.JOB, d.DNAME FROM Dept d, Emp e where d.Deptno = e.Deptno"
      myDataTable.FetchAll = True
      myDataTable.CachedUpdates = False
      myDataTable.UpdatingTable = "Emp"
      myDataTable.UpdatingKeyFields = "EMPNO"
      myDataTable.UpdatingFields = "EMPNO;ENAME;JOB"
      myDataTable.Open()
      Dim row1 As DataRow = myDataTable.Rows.Item(0)
      row1.Item(myDataTable.Columns.Item("ENAME")) = "John Smith"
      myDataTable.Update()
      myDataTable.Close()
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also