A simple COM SDK VB.Net application

In a previous post I demonstrated a simple .Net SDK program, here I will look at a simple COM SDK program.

The code

Here is the code I ended up with in the video.

Sub Main()
    Dim database As New TRIMSDK.Database
    Dim record As TRIMSDK.Record = Nothing
    Dim container As TRIMSDK.Record = Nothing

    Try
        database.Id = "H1"
        database.WorkgroupServerName = "local"
        database.Connect()

        record = database.GetRecord(9000000001)
        container = database.GetRecord("REC_267")

        record.AltContainer = container

        record.Save()
    Finally
        If database IsNot Nothing And database.IsConnected Then
            database.Disconnect()
            System.Runtime.InteropServices.Marshal.ReleaseComObject(database)

            If record IsNot Nothing Then
                System.Runtime.InteropServices.Marshal.ReleaseComObject(record)
            End If

            If container IsNot Nothing Then
                System.Runtime.InteropServices.Marshal.ReleaseComObject(container)
            End If

        End If
    End Try
End Sub
Written on September 1, 2015