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) { MailChimpConnection conn = new MailChimpConnection(connectionString); conn.Open(); MailChimpDataAdapter adapter = new MailChimpDataAdapter("SELECT * FROM Folders", conn); MailChimpCommandBuilder commBuilder = new MailChimpCommandBuilder(adapter); commBuilder.ConflictOption = ConflictOption.OverwriteChanges; commBuilder.KeyFields = "Id, Name"; 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 MailChimpConnection = New MailChimpConnection(connectionString) conn.Open() Dim adapter As MailChimpDataAdapter = New MailChimpDataAdapter("SELECT * FROM Folders", conn) Dim commBuilder As MailChimpCommandBuilder = New MailChimpCommandBuilder(adapter) commBuilder.ConflictOption = ConflictOption.OverwriteChanges commBuilder.KeyFields = "Id, Name" Dim updateComm As String = commBuilder.GetUpdateCommand().CommandText Dim deleteComm As String = commBuilder.GetDeleteCommand().CommandText Console.WriteLine(updateComm) Console.WriteLine(deleteComm) conn.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