Another API question

Post Reply
Posts: 42
Joined: Mon May 19, 2008 10:25 am
OLAP Product: TM1, EV
Version: 9.0 9.1 9.4 9.5 10.1 10.2
Excel Version: 2003 2007 2010 2015
Location: London, UK

Another API question

Post by AnthonyT » Tue Oct 18, 2016 8:00 am

Running TM1 10.2.2 on a local machine
Have Planning Sample and SData up an running, configured to have my machine name as Admin Host (though have also left these blank to use localhost)
Using Visual Studio 2015, and a VB Windows Form Application
Copied the VB BAS file into a new module, and update the data types (64-bit) - as per Alan Kirks tutorial

I have tried all the various different pieces of code that I can find to be able to connect to TM1 through VB, and still can't

I have attached a piece of code that runs on the load of a single form (no controls), and I get the error message SystemServerNotFound when I run it

I have tried changing instances that I am connecting to, having them running and not, having my machine name as the Admin Host, as well as using localhost

I have added all of the variables to a watch, and can see various values being added to them

Any ideas gratefully received

Code: Select all

Private Sub Example1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Dim hUser As Integer

        Dim hPool As Integer
        Dim hServer As Integer

        Dim vServerName As Integer
        Dim vClientName As Integer
        Dim vClientPassword As Integer

        Dim ServerName As New String(Chr(0), 75)
        Dim ClientName As New String(Chr(0), 75)
        Dim ClientPassword As New String(Chr(0), 75)
        Dim ErrorString As New String(Chr(0), 75)

        ' initialize the API
        hUser = TM1SystemOpen()

        'Set the Admin Host Server Name
        TM1SystemAdminHostSet(hUser, "Acer")

        ' Create a Pool Handle
        hPool = TM1ValPoolCreate(hUser)

        ' Establish Login information
        ServerName = "SData"
        ClientName = "admin"
        ClientPassword = "apple"
        vServerName = TM1ValString(hPool, Trim(ServerName), 0)
        vClientName = TM1ValString(hPool, Trim(ClientName), 0)
        vClientPassword = TM1ValString(hPool, Trim(ClientPassword), 0)

        'Log in to a TM1 Server
        hServer = TM1SystemServerConnect(hPool, vServerName, vClientName, vClientPassword)

        ' Check to see if successful...
        If (TM1ValType(hUser, hServer) = TM1ValTypeObject()) Then
            MessageBox.Show("You Logged in Successfully")
        End If
        If (TM1ValType(hUser, hServer) = TM1ValTypeError()) Then
            TM1ValErrorString_VB(hUser, hServer, ErrorString, 75)
            MessageBox.Show("The server handle contains an error - " & Trim(ErrorString))
        End If

        'Close everything
        hPool = TM1SystemServerDisconnect(hPool, vServerName)


    End Sub


That's no moon - that's a space station

Post Reply