Vybe Documentation

Vybe Main page

 

Data Controls & Data Binding

This document describes how the Vybe runtime handles database access and data binding, mimicking both legacy VB6 (ADODB) and modern .NET (ADO.NET) APIs.

Architecture Overview

The data access system follows a multi-layered approach:

  1. VB Expression Layer: The Interpreter parses and evaluates VB commands (e.g., rs.MoveNext(), adapter.Fill(ds)).
  2. Object Proxy Layer: Runtime objects (DbConnection, DbRecordset, etc.) are represented as ObjectData with internal fields like __type and __rs_id.
  3. Internal API (interpreter.rs): Logic that translates VB method calls into Data Access Manager calls and handles lazy loading/binding.
  4. Data Access Manager (data_access.rs): A global manager that drives sqlx to interact with SQLite, PostgreSQL, and MySQL.

Database Components

Supported Providers

Vybe maps various legacy provider strings to modern backends:

Component Instantiation

Components are instantiated by the Interpreter when it encounters a New expression.

VB Class Name Internal __type Purpose
ADODB.Connection / SqlConnection DbConnection Manages database sessions.
ADODB.Command / SqlCommand DbCommand Represents a SQL statement or stored procedure.
ADODB.Recordset DbRecordset VB6-style forward/backward-navigable results.
SqlDataReader / OleDbDataReader DbReader .NET-style forward-only stream of results.
SqlDataAdapter / OleDbDataAdapter DataAdapter Bridge between database and DataSet/DataTable.
System.Data.DataTable DataTable In-memory table of data.
System.Data.DataSet DataSet In-memory cache of multiple tables.

Core Database Methods

DbConnection

DbCommand

DbRecordset (VB6 Style)

DbReader (.NET Style)


Data Binding System

Vybe provides a sophisticated data binding layer that synchronizes the runtime state with the UI frontend.

BindingSource

The BindingSource is the primary orchestrator for UI synchronization.

DataBindings Collection

Every WinForms control in Vybe has a DataBindings collection.


Technical Details

Lazy Loading (auto_fill_data_adapter)

To simplify development, Vybe can automatically fill data adapters. If a BindingSource attempts to access data from an unfilled DataAdapter, the runtime:

  1. Resolves the ConnectionString.
  2. Opens a temporary connection if needed.
  3. Executes the SelectCommand.
  4. Stores the resulting __rs_id on the adapter.

UI Synchronization via Side Effects

The runtime communicates with the frontend using a side_effects queue: