Mike Cowie wrote:jimshen wrote:Hi all,
I found the function TM1SystenOpen getting too many digits which might be the cause for the error "Attempted to read or write protected memory". It gives me 19 digits rather than 9 in normal.
The error stopped at the statement vUserName = TM1ValString(pPoolHandle, sUser, vStingLength)
Anybody can help me to get the solution?
Regards
Jim
Hi Jim,
Can you provide some additional details about things like:
- Your TM1 Version
- A sampling of the TM1 API declarations being used
- A sampling of the TM1 code and variable declarations you are using
TM1SystemOpen returns a handle that is a long integer, and that may ultimately not be a number that is always 9 digits. It is possible that something else is causing the TM1ValString call to fail.
Regards,
Mike
Hi Mike,
[*]The TM1 version is 9.1 SP2.
[*]API Declaration I used are:
Inherits System.Web.UI.Page
Public db As ADODB.Connection
'Const sCube As String = "Sales_Dept"
Const sServer As String = "Dev"
Const sUser As String = "JShen"
Const sPass As String = ""
Dim col() As String
Public hUser As Long
Public pGeneral As Long
Public voDatabase As Long
Declare Sub TM1APIInitialize Lib "tm1api.dll" ()
Declare Function TM1SystemOpen Lib "tm1api.dll" () As Long
Declare Function TM1ValPoolCreate Lib "tm1api.dll" (ByVal hUser As Long) As Long
Declare Sub TM1SystemAdminHostSet Lib "tm1api.dll" (ByVal hUser As Long, ByVal AdminHosts As String)
Declare Function TM1ValIndex Lib "tm1api.dll" (ByVal hPool As Long, ByVal InitIndex As Long) As Long
Declare Function TM1ValString Lib "tm1api.dll" (ByVal hPool As Long, ByVal InitString As String, ByVal MaxSize As Long) As Long
Declare Function TM1SystemServerConnect Lib "tm1api.dll" (ByVal hPool As Long, ByVal sServer As Long, ByVal sClient As Long, ByVal sPassword As Long) As Long
Declare Function TM1SystemServerDisconnect Lib "tm1api.dll" (ByVal hPool As Long, ByVal hServer As Long) As Long
Declare Sub TM1ValPoolDestroy Lib "tm1api.dll" (ByVal hPool As Long)
Declare Sub TM1SystemClose Lib "tm1api.dll" (ByVal hUser As Long)
Declare Sub TM1APIFinalize Lib "tm1api.dll" ()
[*] The sampling of the TM1 code and variable declarations I am using[/list]:
Dim sAdminHost As String = "BI-TM1-SERVER"
Dim pPoolHandle As Long
Dim vPassword, vServerName, vUserName As Long
Dim vServerHandle, vResult As Long
Dim vStringLength As Long
TM1APIInitialize()
hUser = TM1SystemOpen
TM1SystemAdminHostSet(hUser, sAdminHost)
pPoolHandle = TM1ValPoolCreate(hUser)
'vStringLength = TM1ValIndex(pPoolHandle, 10)
vStringLength = Left(pPoolHandle, 10)
vUserName = TM1ValString(pPoolHandle, sUser, vStringLength)
vPassword = TM1ValString(pPoolHandle, sPass, vStringLength)
vServerName = TM1ValString(pPoolHandle, sServer, vStringLength)
The interesting thing is that same codes in VBA (MS Acess) work fine with same TM1 server. It suggests me the problem should be TM1 and VB.Net. Not sure can have some way walk around it ?
Regards
Jim