AltDB: An Open-Source Drop-in Replacement for AsDB (AS 6 Compatible)

Hello B&R Community,

With the discontinuation of the AsDB library in Automation Studio 6, projects relying on native SQL Server connectivity face migration challenges.

To help address this gap, I have published AltDB, an open-source, clean-room drop-in replacement library designed to restore MS SQL Server connectivity in Automation Studio 6 without requiring changes to existing application code.

Overview

AltDB is written directly against the published Microsoft Tabular Data Stream ([MS-TDS]) wire specification, with no FreeTDS or LGPL licensing restrictions. It preserves the exact function block interfaces, error numbers, and asynchronous state-machine behavior (ERR_FUB_BUSY) of legacy AsDb:

  • dbConnect() / dbConnectEnc()
  • dbExecuteSql()
  • dbFetchNextRow()
  • dbGetData()
  • dbGetAffectedRows()
  • dbGetColumnCount()
  • dbGetErrorMessage()
  • dbDisconnect()
  • dbGetInfo()

Using AltDB in an Existing Project

Replacing AsDB in an existing machine application takes just a few steps:

  1. Download and unzip AltDB.zip from the latest GitHub release.
  2. In Automation Studio, delete the legacy AsDb library from your Logical View if it has not already been removed by the AS 6 project upgrade.
  3. Click the Libraries button on the Automation Studio toolbar and select Existing library….
  4. Navigate to and select the extracted AltDB folder to import it into your project.
  5. Rebuild your project. Existing task code, function block calls, and cyclic state machines remain unchanged.

Testing with ARsim and Docker

The repository includes a complete Automation Studio sample project along with a preconfigured docker-compose.yml to make local testing straightforward:

  1. Clone the repository and run:

    docker compose up -d
    

    This spins up an MSSQL Server container and automatically seeds a TestDb database configured with compatibility level 120 (SQL Server 2014 mode) on localhost:1433.

  2. Open the included sample project in Automation Studio.

  3. Build and transfer the project to ARsim.

  4. Open the Watch window for the included recipe task and trigger eCMD_CONNECT to test connections, table creation, record insertion, and queries.

Current Testing Status & Disclaimer

AltDB has currently been minimally validated. Feedback, bug reports, and ways in which behavior differs from AsDB are welcome.

GitHub Repository: br-automation-community/AltDB: An alternative database connection library for B&R targets

Latest Releases: Releases · br-automation-community/AltDB

I hope this helps anyone transitioning legacy AsDb codebases to Automation Studio 6.

8 Likes