interface DownloadTableData
Verkapselt Informationen für eine Downloadtabelle für eine Synchronisation. Richten Sie mit dieser Schnittstelle die Datenvorgänge ein, die auf eine Synchronisationsclient-Site geladen werden.
Angenommen, Sie haben beispielsweise die folgende Tabelle:
CREATE TABLE remoteOrders ( pk INT NOT NULL, col1 VARCHAR(200), PRIMARY KEY (pk) ); |
Im folgenden Beispiel wird mit der Methode DownloadData.GetDownloadTableByName eine DownloadTableData-Instanz zurückgegeben, die die remoteOrders-Tabelle darstellt.
// The method used for the handle_DownloadData event public void HandleDownload() { // _cc is a DBConnectionContext instance. // Get the DownloadData for the current synchronization. DownloadData my_dd = _cc.GetDownloadData(); // Get the DownloadTableData for the remoteOrders table. DownloadTableData td = my_dd.GetDownloadTableByName("remoteOrders"); // User defined-methods to set download operations. SetDownloadUpserts(td); SetDownloadDeletes(td); // ... } |
In diesen Beispiel verwendet die Methode SetDownloadInserts die Methode DownloadTableData.GetUpsertCommand, um einen Befehl für die Zeilen abzurufen, die Sie einfügen oder aktualisieren möchten. IDbCommand enthält die Parameter, die auf die Werte gesetzt werden, die in die entfernte Datenbank eingefügt werden sollen.
void SetDownloadInserts(DownloadTableData td) { IDbCommand upsert_cmd = td.GetUpsertCommand(); IDataParameterCollection parameters = upsert_cmd.Parameters; // The following method calls are the same as the following SQL statement: // INSERT INTO remoteOrders(pk, col1) values(2300, "truck"); ((IDataParameter) (parameters[0])).Value = (Int32) 2300; ((IDataParameter) (parameters[1])).Value = (String) "truck"; if (upsert_cmd.ExecuteNonQuery() > 0) { // Insert was not filtered. } else { // Insert was filtered because it was uploaded // in the same synchronization. } } |
Die Methode SetDownloadDeletes ruft mit der Methode DownloadTableData.GetDeleteCommand einen Befehl für Zeilen ab, die Sie löschen möchten.
void SetDownloadDeletes(DownloadTableData td) { IDbCommand delete_cmd = t2_download_dd.GetDeleteCommand(); // The following method calls are the same as the following SQL statement: // DELETE FROM remoteOrders where pk = 2300; IDataParameterCollection parameters = delete_cmd.Parameters; ((IDataParameter) (parameters[0])).Value = (Int32) 2300; delete_cmd.ExecuteNonQuery(); } |
GetDeleteCommand-Methode
GetLastDownloadTime-Methode
GetName-Methode
GetSchemaTable-Methode
GetUpsertCommand-Methode
Kommentieren Sie diese Seite in DocCommentXchange. Senden Sie uns Feedback über diese Seite via E-Mail. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |