User Tools

Site Tools




22.4.2 Class Connections (gb.db)

The class lists all predefined DB connections that are defined in the IDE in the “Connections” project folder. You must include the gb.desktop component in your project if you want to ensure that the password entered via the IDE for the defined DB connection is automatically retrieved. Otherwise, you must provide the password for MySQL and PostgreSQL yourself! Properties

The Connections class has two properties:

PropertyData typeDescription
CountIntegerDelivers the number of DB connections defined in the project.
KeyStringDelivers the key of the last enumerated predefined DB connection.

Table : Properties of the Connections class

A predefined DB connection is one that has been defined in the IDE via the context menu> Connections> New connection in the project browser. This creates a text file in the hidden.connection directory of the project that can be accessed by the runtime environment. Methods

The Connections class has these two methods:

MethodReturn typeDescription
Create(Name As String) ConnectionReturns a DB connection object defined in the IDE and initialises it. `Name` is the name of the DB connection defined in the IDE. The database defined by the DB connection object is created if it does not exist. The database tables and database indices are created and initialised from the internal template description of the DB connection.
Exist(Name As String)BooleanReturns TRUE if a specific predefined connection exists. `Name` is the name of the DB connection defined in the IDE.

Table : Methods of the Connections class Examples

The following source code provides an enumeration of all predefined DB connection objects:

Dim hConnection As Connection
For Each hConnection In Connections

This source code section provides a predefined DB connection by name:

Dim hOneConnection As Connection
hOneConnection = Connections [ Name As String ]

This opens a predefined DB connection and closes it at the end of the programme:

Public Sub Form_Open()
  If Not Connections["Connection1"].Opened Then Try Connections["Connection1"].Open()
  If Error Then
    Message.Error("Unable to connect to the database")
Public Sub Form_Close()
The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k22/k22.4/k22.4.2/start.txt · Last modified: 27.04.2024 by emma

Page Tools