Imports System
Imports Fujitsu.Shunsaku
Imports System.ComponentModel
Class SampleDirectAccessDelete
  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 = "DirSvr1"
      service.Port = 33101
      service.ShunsakuFile = "shunsakuFile1"
      service.Connect()
      '' Create ShunKeyRequirement object for deleting data
      Dim keyReq As ShunKeyRequirement = new ShunKeyRequirement()
      keyReq.KeyName = "key"
      '' Add the direct access key of the data to be deleted
      keyReq.Records.Add( new ShunRecord() )
      keyReq.Records( 0 ).Key = "0001"
      ''Update course information
      service.DeleteByKey( keyReq )
      Console.WriteLine( "Deletion 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 |