KeyFields Property (SQLiteCommandBuilder)
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) {
SQLiteConnection conn = new SQLiteConnection(connectionString);
conn.Open();
SQLiteDataAdapter adapter = new SQLiteDataAdapter("SELECT * FROM Dept", conn);
SQLiteCommandBuilder commBuilder = new SQLiteCommandBuilder(adapter);
commBuilder.ConflictOption = ConflictOption.OverwriteChanges;
commBuilder.KeyFields = "DeptNo, DName";
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 SQLiteConnection = New SQLiteConnection(connectionString)
conn.Open()
Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter("SELECT * FROM Dept", conn)
Dim commBuilder As SQLiteCommandBuilder = New SQLiteCommandBuilder(adapter)
commBuilder.ConflictOption = ConflictOption.OverwriteChanges
commBuilder.KeyFields = "DeptNo, DName"
Dim updateComm As String = commBuilder.GetUpdateCommand().CommandText
Dim deleteComm As String = commBuilder.GetDeleteCommand().CommandText
Console.WriteLine(updateComm)
Console.WriteLine(deleteComm)
conn.Close()
End Sub