BusinessObjects Board

Retrieve information from the BI 4.x InfoStore with VB .NET

Hi,
I have a program written in Visual Basic 6 in order to read from the BI 4.x InfoStore, that has been working perfectly for years.
I am desesperately trying to rewrite it in VB .NET, but I can’t make it work.

Here is a sample code:


Sub Main()

  Dim oBoSessionManager As CrystalEnterpriseLib.SessionMgr
  Dim oBoSession As CrystalEnterpriseLib.EnterpriseSession
  Dim oBoInfostore As CrystalInfoStoreLib.InfoStore
  Dim sReqUti As String
  Dim oResUti As Object
  Dim oUti As Object
  Dim sUtiid As String
  Dim sCuid As String
  Dim sUtilisateur As String
  Dim sNomLong As String


  'En cas d'erreur aller au (non-)traitement de l'erreur (!)
  On Error GoTo Erreur

  'Connexion au référentiel de BO
  oBoSessionManager = CreateObject("CrystalEnterprise.SessionMgr")
  oBoSession = oBoSessionManager.Logon(My.Settings.BoUtilisateur, My.Settings.BoMotdepasse, My.Settings.BoSysteme, My.Settings.BoAuthentification)
  oBoInfostore = oBoSession.Service("", "InfoStore")
 
  'Liste des utilisateurs
  sReqUti = "SELECT TOP 1000000 SI_ID, SI_CUID, SI_NAME, SI_USERFULLNAME, SI_CUSTOM_MAPPED_ATTRIBUTES, SI_EMAIL_ADDRESS, SI_NAMEDUSER, SI_ALIASES, SI_CREATION_TIME, SI_UPDATE_TS, SI_LASTLOGONTIME"
  sReqUti = sReqUti & " FROM CI_SYSTEMOBJECTS WHERE SI_KIND IN (" & sKindUtilisateurs & ") ORDER BY SI_NAME"
  Set oResUti = oBoInfostore.Query(sReqUti)
  
  For Each oUti In oResUti
    'Initialisation à vide des propriétés facultatives
    sNom = ""
    sPrenom = ""
    sInfos = ""
    sDateDCnx = ""
    
    sUtiid = CStr(oUti.Properties("SI_ID"))
    sCuid = Replace(oUti.Properties("SI_CUID"), "'", "''")
    sUtilisateur = Replace(oUti.Properties("SI_NAME"), "'", "''")
    sNomLong = Replace(oUti.Properties("SI_USERFULLNAME"), "'", "''")
	
  'Fermeture
  Set oResUti = Nothing
  
  'Sortie pour ne pas passer par l'erreur
  Exit Sub
  
Erreur:

    If Err = -2147210697 Then
        'property not filled or not exists
        Resume Next
    End If
    
    Debug.Print "Problème sur Utilisateur SI_ID = " & sUtiid
    Debug.Print Error(Err)

End Sub

The code works fine until the line:
sUtiid = CStr(oUti.Properties(“SI_ID”))

But then all my string variables get the same value: “System.__ComObject”

Could someone help me read the user properties (SI_*) I’ve selected in my query?

Thanks a lot


Lyb :fr: (BOB member since 2019-09-25)

Not certain it will work, but try:

sUtiid = CStr(oUti.Properties(“SI_ID”).Value)


joepeters :us: (BOB member since 2002-08-29)

Yes, it does! :smiley:
Thank you so much, joe!


Lyb :fr: (BOB member since 2019-09-25)

Glad I could help!


joepeters :us: (BOB member since 2002-08-29)