Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX -
Contents Index PreviousNext

Part 1 The Basic for Developing Application> Chapter 7 Shunsaku File> 7.4 Operating Multiple Shunsaku Files in One Transaction

7.4.2 Sample Code for .NET API

The following code is the sample code for operating multiple Shunsaku Files in one transaction using .NET API.

/*
 * This program assumes that the following variables have been declared
 *  sPerson :The information of employees to be added
 *  sQuery :Character string containing search expression
 *  sReturn :Character string containing return expression
 *  updateData :Character string containing update data
 */
// Create ShunService object
// Host name in the connection destination: DirSvr1
// Port number: 33101
// Shunsaku File name: fileA

ShunService service = new ShunService();
service.Host = "DirSvr1";
service.Port = 33101;
service.ShunsakuFile = "fileA";
service.Connect();

// Turn off auto-commit mode
service.AutoCommit = false;

ShunRecordCollection insertRecords = new ShunRecordCollection();
ShunRecord personRecord = new ShunRecord( sPerson );
insertRecords.Add( personRecord );

// Add data
service.Insert( insertRecords );

//Switch Shunsaku File in the connection destination to fileD
service.ChangeShunsakuFile("fileD");

ShunSearchRequirement req = new ShunSearchRequirement();
req.QueryExpression = sQuery;
req.ReturnExpression = sReturn;
// Search the update data
ShunResultSet rs = service.Search( req );
ShunRecord updateRecord = null;
foreach ( ShunRecord record in rs.Records ) {
  updateRecord = record;
}
updateRecord.Data = updateData;

ShunRecordCollection updateRecords = new ShunRecordCollection();
updateRecords.Add( updateRecord );

//Update data
service.Update( updateRecords );

// Commit the updates made so far
service.Commit();

service.Disconnect();

Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006