Using AlphaDAO with Xbasic


Includes: What is AlphaDAO?, terminology, the AlphaDAO object, and creating an object,

What is AlphaDAO?

AlphaDAO provides Xbasic program access to SQL databases such as Microsoft SQL Server, Oracle, MySQL, and Microsoft Access. This functionality extends the familiar Alpha Anywhere database features that also supported .DBF files.

While not a part of AlphaDAO, it is important to note that you may also read SQL database data by creating passive-link tables. You may then browse these tables and make updates, open a form or report, and perform Xbasic commands.


This document refers to SQL databases and tables as "back-end" databases and tables, and to Alpha Anywhere tables as local tables.

Goal of this Document

This document provides a few short examples showing how you can use AlphaDAO in your Xbasic scripts. In the examples that follow we will often show more than one way to achieve the desired goal.

Following the Examples

All of the examples in this document can be followed from Alpha Anywhere's Interactive window, or by creating Xbasic scripts. The examples all use the Alphasports.MDB Microsoft Access database. This database ships with Alpha Anywhere and is located in the c:\Program Files\a5v12\MDBFiles folder. If you want to work with data in a different database, the concepts learned from the example here will still apply to your database. In this document, the code that you should type in the Interactive window, or into your scripts, is shown in blue like this:


The AlphaDAO Objects

AlphaDAO comprises many objects. You will use their properties and methods when you do your programming. Some of these objects are reserved for use by Alpha Software's development engineers. At least 90 percent of the time, you will find that you need only use 4 objects to build your applications. This tutorial will examine these objects:

  • SQL::Connection

  • SQL::Arguments

  • SQL::ResultSet

  • SQL::CallResult

Advanced developers will occasionally use the following objects and enumerations.

  • SQL::DataTypeInfo

  • SQL::IndexColumnInfo

  • SQL::IndexInfo

  • SQL::IntermediateType Enumerated Type

  • SQL::Schema

  • SQL::TableInfo

Creating an Object

You can create an object by using the DIM statement. Afterwards, you will have to set one or more properties of the object, depending on its type and the context.

dim ti as SQL::TableInfo
dim ii as SQL::IndexInfo
dim ic as SQL::IndexColumnInfo
ti.Name = "MyTable"
ii.Name = "Primary_Key"
ii.PrimaryKey = .t.
ic.Name = "MyColumnName"

Frequently you will find a "child" object to be a property of a "parent" object. In these cases the "parent" object has already "DIMmed" it for you.

See Also