This property is used when the ConflictOption property is set to OverwriteChanges, otherwise all columns will be used in the WHERE clause.
If KeyFields is nonempty, its value is used as the list of columns for the WHERE clause. If KeyFields is empty, the primary key columns are used.
public void UseKeyFields(string connectionString) { FreshBooksConnection conn = new FreshBooksConnection(connectionString); conn.Open(); FreshBooksDataAdapter adapter = new FreshBooksDataAdapter("SELECT * FROM Client", conn); FreshBooksCommandBuilder commBuilder = new FreshBooksCommandBuilder(adapter); commBuilder.ConflictOption = ConflictOption.OverwriteChanges; commBuilder.KeyFields = "Id, LastName"; string updateComm = commBuilder.GetUpdateCommand().CommandText; string deleteComm = commBuilder.GetDeleteCommand().CommandText; Console.WriteLine(updateComm); Console.WriteLine(deleteComm); conn.Close(); }
Public Sub UseKeyFields(ByVal connectionString As String) Dim conn As FreshBooksConnection = New FreshBooksConnection(connectionString) conn.Open() Dim adapter As FreshBooksDataAdapter = New FreshBooksDataAdapter("SELECT * FROM Client", conn) Dim commBuilder As FreshBooksCommandBuilder = New FreshBooksCommandBuilder(adapter) commBuilder.ConflictOption = ConflictOption.OverwriteChanges commBuilder.KeyFields = "Id, LastName" Dim updateComm As String = commBuilder.GetUpdateCommand().CommandText Dim deleteComm As String = commBuilder.GetDeleteCommand().CommandText Console.WriteLine(updateComm) Console.WriteLine(deleteComm) conn.Close() End Sub