UpdateData

Description

Updates the database with the data in the filled DataSet.

If "inTransaction" is set to true, the update will be performed in a transaction. If an error occurs, a rollback for the whole update will be executed. The "transactionKey" parameter must be specified if "inTransaction" is set to true. Since the operation will perform a rollback if an error occurs, the return value will not have any function when the a transaction is used.
Signature
ErrorMessage[] UpdateData(string key, TransferDef transferDef, DataSet ds, bool applyRules, bool inTransaction, int transactionKey)

Parameters

Name Data Type Description

key

string required

The authentication key

transferDef

TransferDefBase required

The transfer definition object. It can be a SimpleTransferDef or a TransferDef object.

ds

DataSet

DataSet to be Updated.

applyRules

bool

Indicates if data in the update should be verified against constraints in the panel. For instance that data updated for a single match a code from the answer list of the single.

inTransaction

bool

True runs the update in a transaction, False does not.

transactionKey

int

A key, defined by the user to be able to track if the transaction succeded or not (cannot be a negative number). See GetTransactionStatus.

Response

Data Type Description

Example

//***************************************************
//
// GetData
// UpdateData
//
//***************************************************

// Initiate webservice
SurveyDataSoapClient sd = new SurveyDataSoapClient();

// Create a transfer definition
//
TransferDef transferDef = SurveyDataUtil.NewTransferDef(
    projectID,
    false,
    DatabaseType.Production);

// Only choose loop-level named "l2"
TransferLevel transferLevel = SurveyDataUtil.NewTransferLevel(
    "l2",
    false);

// Only choose form called "myopenquestion"
TransferForm transferForm = SurveyDataUtil.NewTransferForm(
    "myopenquestion",
    true);
transferLevel.Forms =
    (TransferForm[])SurveyDataUtil.Add(transferLevel.Forms,transferForm,typeof(TransferForm));
transferDef.Levels =
    (TransferLevel[])SurveyDataUtil.Add(transferDef.Levels,transferLevel,typeof(TransferLevel));


ResponseToken token = null;
TransferResult result = null;

//Updates the data for each roundtrip.
do
{
    result = sd.GetData(key,transferDef,token);
    token = result.ResponseToken;

    DataTable dt = result.Result.Tables[0];

    // Add the text "ABC" to the existing text
    // in each response
    for(int i=0;i<= dt.Rows.Count-1;i++)
        dt.Rows[i]["myopenquestion"] +="ABC";

    // Update database
    sd.UpdateData(key,transferDef,result.Result,false, false,-1);
}
while(!result.ResponseToken.LastDataSet);