Imports System
Imports Fujitsu.Shunsaku
Imports System.ComponentModel
Class SampleInsert
Shared Public Function Main( ByVal args() As String ) As Integer
Dim service As ShunService = Nothing
Try
'' Create ShunService
service = new ShunService()
'' Connect Shunsaku by specifying the host name and port number
service.Host = "DirSrv1"
service.Port = 33101
service.Connect()
'' Create ShunRecordCollection for adding data
Dim insertRecords As ShunRecordCollection = new ShunRecordCollection()
'' Create ShunRecord for adding data
Dim record As ShunRecord = new ShunRecord()
'' Specifiy data
record.Data = String.Concat( _
"<document>", _
" <base>", _
" <name>Hotel 9</name>", _
" <city>Adelaide</city>", _
" <address>Belair, Adelaide</address>", _
" <detail>http://xxxxx.com.au</detail>", _
" <price>150</price>", _
" </base>", _
" <information>", _
" <date>2006/07/18</date>", _
" </information>", _
"<note>No-smoking room with en-suite bathroom and toilet available, 5 minutes' walk to subway station XX</note>", _
"</document>" )
'' Add to the collection
insertRecords.Add( record )
'' Add data
service.Insert( insertRecords )
Console.WriteLine( "Addition complete" )
'' Close the connection to Shunsaku
service.Disconnect()
Catch e As ShunContinuousException
'' Processing to perform if ShunContinuousException occurs
Try
If Not service Is Nothing And service.State = ShunConnectionState.Open Then
service.Disconnect()
End If
Catch ex As ShunException
Console.WriteLine( "Error message : {0}", ex.Message )
End Try
Console.WriteLine( "Error message : {0}", e.Message )
Catch e As ShunConnectionTerminatedException
'' Processing to perform if ShunConnectionTerminatedException occurs
Console.WriteLine( "Error message : {0}", e.Message )
End Try
End Function
End Class |