Connect to CDB

Problem Description

Hint

To connect to the CDB, first the workbook must be configured.

  • Set the directory of the example in e.g. C:/exampleFolder

  • In the directory please load a C:/exampleFolder/exampleCDB.cdb database

  • Set the workbook in the directory and name it C:/exampleFolder/exampleWorkbook.xlsm

Probem Solution

An example how to connect to CDB is given below.

Example: VBA - Connect to CDB
Global analysisPath As String

'Connect to CDB
Public Sub connect()
Dim Filename As String
Dim Index As Long

'Filename = full path with name of the cdb
'e.g. Filename = "C://test/test.cdb"
Filename = "S:\test\test.cdb"

'To connect to the CDB we will use
Index = sof_cdb_init(Filename, 99)

MsgBox "Index: " & Index

'This outputs the status of the CDB, please refer to cdbase.chm for more details
MsgBox "CDB Status: " & sof_cdb_status(Index)

'Close the CDB
Call sof_cdb_close(0)

'Lets check what is the status after closing the cdb
MsgBox "CDB Status after sof_cdb_close: " & sof_cdb_status(Index)
End Sub

The configured workbook can be found in:

C:\<sofistik_installation>\2020\SOFiSTiK 2020\interfaces\examples\vba\configure_workbook