Interstage Shunsaku Data Manager アプリケーション開発ガイド - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX共通 -
目次 索引 前ページ次ページ

第2部 APIでのアプリケーション開発> 第10章 .NET APIのアプリケーション開発> 10.3 .NET APIの使用方法> 10.3.3 データの更新

10.3.3.1 データを追加する

データを追加するには、Insertメソッドを使用します。

データを追加する場合の流れについて、以下の図に示します。

[図: データを追加する場合の流れ]

■C# .NETの記述例

ShunService service = new ShunService();
service.Connect();

String data = "<document>"
             +"    <base>"
                     :
             +"    </base>"
             +"    <information>"
                     :
             +"    </information>"
             +"</document>";

ShunRecordCollection recCol = new ShunRecordCollection();                       (1)
ShunRecord record = new ShunRecord( data );                                     (2)
recCol.Add( record );                                                           (3)

service.Insert( recCol );                                                       (4)

service.Disconnect();

■VB .NETの記述例

Dim service As New ShunService()
service.Connect()

Dim data As String = "<document>" _
                  &"    <base>" _
                          :
                  &"    </base>" _
                  &"    <information>" _
                          :
                  &"    </information>" _
                  &"</document>"


Dim recCol As New ShunRecordCollection()                                        (1)
Dim record As New ShunRecord( data )                                            (2)
recCol.Add( record )                                                            (3)

service.Insert( recCol )                                                        (4)

service.Disconnect()

◆(1) ShunRecordCollectionオブジェクトの作成

ShunRecordCollectionオブジェクトを作成します。

◆(2) 追加するデータの設定

追加したいXML文書をShunRecordオブジェクトに設定します。XML文書を設定するには、以下のメソッドを使用します。使用可能なメソッドについては以下の表を参照してください。

[表:XML文書を設定するメソッド一覧]

メソッド名またはプロパティ名

機能説明

ShunRecord(String data)

XML文書をコンストラクタの引数に指定してShunRecordオブジェクトを生成します。

ShunRecord(Stream stream)

XML文書をコンストラクタの引数に指定してShunRecordオブジェクトを生成します。

Dataプロパティ

XML文書を指定します。

setData(Stream stream)

XML文書を指定します。

◆(3) ShunRecordオブジェクトの設定

ShunRecordオブジェクトを、ShunRecordCollectionオブジェクトに設定します。

ShunRecordオブジェクトを設定するには、以下のメソッドを使用します。使用可能なメソッドについては以下の表を参照してください。

[表:ShunRecordオブジェクトを設定するメソッド一覧]

メソッド名またはプロパティ名

機能説明

Add(ShunRecord record)

ShunRecordをShunRecordCollection の末尾に追加します。

AddRange(ShunRecord[] records)

ShunRecord配列の要素を ShunRecordCollectionの末尾にコピーします。

Insert(int index, ShunRecord record)

ShunRecordCollection 内の指定したインデックス位置に、ShunRecord を挿入します。

Item[int index]

指定したインデックス位置のShunRecordを置き換えます。
C# .NETでは、このプロパティは ShunRecordCollectionクラスのインデクサになります。

◆(4) 追加の実行

追加の実行はInsertメソッドを使用します。


目次 索引 前ページ次ページ

All Rights Reserved, Copyright(C) 富士通株式会社 2006