KeyFields Property (SugarCommandBuilder)
Gets or sets string containing list of key field names separated by semicolon. They are used to generate update commands.
public new string KeyFields {get; set;}
'Declaration
Public Shadows Property KeyFields As String
Property Value
The string containing list of key field names separated by semicolon.
The following example demonstrates how UPDATE and DELETE statements are generated.
public void UseKeyFields(string connectionString) {
SugarConnection conn = new SugarConnection(connectionString);
conn.Open();
SugarDataAdapter adapter = new SugarDataAdapter("SELECT * FROM Campaigns", conn);
SugarCommandBuilder commBuilder = new SugarCommandBuilder(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 SugarConnection = New SugarConnection(connectionString)
conn.Open()
Dim adapter As SugarDataAdapter = New SugarDataAdapter("SELECT * FROM Campaigns", conn)
Dim commBuilder As SugarCommandBuilder = New SugarCommandBuilder(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