UpdateData

Description

Updates the database with the data in the filled DataSet. If not using .Net, you should consider using UpdateDataGeneral instead.

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).

Response

Data Type Description

Example

var communityPanelSoapClient = new CommunityPanelSoapClient();

// Filter for retrieving all data for panelists with id less than 1000
var transferDef = new TransferDef
{
    ProjectId = "p123456789",
    AllChildrenLevels = true,
    Where = new WhereClause
    {
        Item = new BinaryComparison()
        {
            Type = ComparisonType.LessThan,
            Item = new QueryForm
            {
                Name = "responseid",
            },
            Item1 = new QueryConstant
            {
                Value = "1000"
            }
        }
    },
    Key = "responseid"

};

// Get existing data
var transferResult = communityPanelSoapClient.GetData(key, transferDef, null);
var panelData = transferResult.Result;
var dataTable = panelData.Tables["responseid"];
var columnToUpdate = dataTable.Columns.IndexOf("test");

// Loop over records and change value in field "test"
foreach (DataRow dataRow in dataTable.Rows)
{
    dataRow.SetField(columnToUpdate, "test value");
}

// Send updated data back to panel.
var errorMessages = communityPanelSoapClient.UpdateData(key, transferDef, panelData, false, false, -1);

if (errorMessages.Length < 1)
{
    Console.WriteLine("Data has been updated");
}
else
{
    Console.WriteLine("Update failed for these records:");
    Array.ForEach(errorMessages, Console.WriteLine);
    Console.WriteLine();
}