UpdatingKeyFields Property (DbDataTable)
Gets or sets string containing list of key field names separated by semicolon. They are used to generate update commands.
public string UpdatingKeyFields {get; set;}
'Declaration
Public Property UpdatingKeyFields As String
Property Value
The string containing list of key field names separated by semicolon.
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 Test.Dept d, Test.Emp e where d.Deptno = e.Deptno";
myDataTable.FetchAll = true;
myDataTable.CachedUpdates = false;
myDataTable.UpdatingTable = "Test.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 Test.Dept d, Test.Emp e where d.Deptno = e.Deptno"
myDataTable.FetchAll = True
myDataTable.CachedUpdates = False
myDataTable.UpdatingTable = "Test.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
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