ISCSession Interface

The following table contains information on the ISCSession interface:

Signature

Description

Valid Arguments

VARIANT_BOOL Open(IUnknown * Unit, VARIANT Level [optional], VARIANT Flags [optional])

Binds self to the persistence unit identified by the Unit parameter

Unit:

  • Pointer to a persistence unit that was loaded. Attaches the persistence unit to the session.

Level:

  • Empty � Defaults to data level access (SCD_SL_M0).
  • SCD_SL_M0 � Data level access.

Flags:

  • Empty � Defaults to SCD_SF_NONE.
  • SCD_SF_NONE � Specifies that other sessions can have access to the attached persistence unit.
  • SCD_SF_EXCLUSIVE � Specifies that other sessions cannot have access to the attached persistence unit.

Example 6

The following example illustrates how to open a session using C++. The example uses the Application object created in Example 1 and the CreateNewModel function from Example 4:

ISCSessionPtr OpenSession(ISCApplicationPtr & scAppPtr)
{     
      ISCSessionCollectionPtr scSessionColPtr = scAppPtr->GetSessions();
      ISCSessionPtr scSessionPtr = scSessionColPtr->Add();  // add a new session
      ISCPersistenceUnitPtr scPUnitPtr = CreateNewModel(scAppPtr); // From Example 4
      
      CComVariant varResult = scSessionPtr->Open(scPUnitPtr, (long) SCD_SL_M0); // open unit
      if (varResult.vt == VT_BOOL && varResult.boolVal == FALSE)
         return NULL;
      return scSessionPtr;
}

The following example illustrates how to open a session using Visual Basic .NET. The example uses the Application object created in Example 1 and the CreateNewModel function from Example 4:

Public Function OpenSession(ByRef scApp As SCAPI.Application) As SCAPI.Session
      Dim scSessionCol As SCAPI.Sessions
      Dim scPUnit As SCAPI.PersistenceUnit
      scSessionCol = scApp.Sessions
      OpenSession = scSessionCol.Add  'new session
   
      scPUnit = CreateNewModel(scApp)  ' From Example 4
      scSession.Open(scPUnit, SCD_SL_M0)  ' open the persistence unit
End Sub