SQL in Desktop

Description

Working with SQL in desktop applications.

Name
Description
ADO Import Genie

The ADO Import Genie allows you to import data from remote databases, such as Microsoft Access, Microsoft SQL Server, MySQL, Oracle, or any other database for which an ADO provider or ODBC driver is available. The ADO Import Genie also imports data from the most current versions of Microsoft Excel.

Close Connection to SQL Database

The Close Connection to SQL Database action allows you to close a connection to a SQL database in a Desktop Application. This action must be preceded by the Connect to SQL Database action.

Columns from a Table or View

This approach to defining a SQL SELECT statement requires less knowledge of SQL.

Connection String Dialog

The Connection String dialog allows you to define a connection with a SQL back-end database in your Desktop application. You can open the Connection String dialog from the Database Explorer.

Connections

Connections to SQL databases are implemented in two parts. The server owns the data. It may be either local to the client computer or it may be accessed over a local, wide area, or even an internet connection. A single server will handle requests from many users at a time. Most servers support the use of transactions, which insure that a set of changes made by a single user are visible to other users all at once.

Connections Dialog

The Connections dialog allows you to define a connection with an ADO or SQL back-end database in a Desktop Application.

Create ad hoc DataSource

Connecting to a data source requires a connection string. There are 2 different approaches to using a connection string.

Create Database Connection String

To display the Create SQL Connection String dialog, click Add/Edit Saved Connections > New > Build. First select the type of database you want to connect to in the Connection Type list. The options are:

Creating a Table and Exporting Selected Records to the Back-End

The following script selects records from the Alpha Sports customer.dbf table and writes them to a new table named "CustomerX" in the Access AlphaSport.mdb database.

Creating a WHERE Clause

A WHERE clause filters (limits) the records that you will select with a SQL statement.

Custom SQL Select Statement or Stored Procedure

Procedural steps for customizing SQL statements and stored procedures in Desktop Applications.

Deleting Records in a Back-end Database

To delete records into a back-end database, you use the SQL DELETE command. The general syntax of the DELETE command is:

Execute DELETE Query on a SQL Database

The Execute DELETE Query on a SQL Database action allows you to delete one or more records from a remote SQL database. Alpha Anywhere will use AlphaDAO (Alpha Data Access Objects) to connect to the remote database.

Execute INSERT Query on a SQL Database

The Execute INSERT Query on a SQL Database action allows you to insert one or more records into a remote SQL database. Alpha Anywhere will use AlphaDAO (Alpha Data Access Objects) to connect to the remote database.

Execute SELECT Query on a SQL Database

The Execute SELECT Query on a SQL Database action allows you to execute a SQL SELECT statement (a query) on a remote SQL database (or Excel spreadsheet) to retrieve one or more record(s). Alpha Anywhere will use AlphaDAO (Alpha Data Access Objects) to connect to the remote database.

Execute UPDATE Query on a SQL Database

The Execute UPDATE Query on a SQL Database action allows you to modify one or more records in a remote SQL database. Alpha Anywhere will use AlphaDAO (Alpha Data Access Objects) to connect to the remote database.

Export Database Tables to SQL Dialog

The Export Database Tables to SQL dialog helps you export one or more Alpha Anywhere .DBF tables to a back-end SQL database.

Export Table to SQL - Advanced Settings Dialog

The Export Table to SQL - Advanced Settings dialog allows you to modify the SQL INSERT statement that adds records to a back-end database table and the SQL CREATE TABLE statement that creates a new table.

Export Table to SQL Dialog

The Export Table to SQL dialog helps you export a local Alpha Anywhere table to a back-end SQL database.

Exporting a Table to the Back-End

This example will show how to export the Alpha Anywhere AlphaSports customer table to the Access AlphaSports database.

Getting Started with Enterprise Reporting

Alpha Anywhere reporting allows you to selectively retrieve records from a table, order and group them, calculate group totals, and then print the resulting report, save it to a file, or send it to a remote user as an email attachment. Enterprise Reporting adds the ability to do all this with data that resides in an external ODBC compatible database.

Import Table from SQL Dialog

The Import Table from SQL dialog helps you import a SQL back-end table to an Alpha Anywhere .DBF table.

Optimized Active-Link Sets

In Sets that are based on active-link tables, there are now dramatic performance improvements under certain conditions. The conditions under which you will see performance improvements are in Sets with one-to-one links, were the one-to-one links at a given level in the Set are based on the same SQL backend database.

Overview - Client/Server Applications

Alpha Anywhere's Enterprise software gives you the ability to read and write to back-end database products in a manner similar to the way you would read and write to an Alpha Anywhere table. The term "back-end database" refers to the following ODBC compatible database products which support the SQL query language.

Reading Through a ResultSet

Suppose you have executed the following code that retrieves a SQL::ResultSet from the back-end database.

Retrieving Data to a Property Array

Retrieving data to a property array allows you to immediately manipulate it with your program. First, create a SQL::Connection() object and a pointer array to receive the data. The array only needs to have a single element.

Select Column or Expression Dialog

The Select Column or Expression dialog helps you define and validate expressions used in the SQL Genie. The value that you see in the Enter expression text box is returned to the calling dialog when you click OK.

Specify a Value or Expression Dialog

The Specify a Value or Expression dialog helps you define and validate expressions used in the SQL Genie. The value that you see in the Enter expression text box is returned to the calling dialog when you click OK.

SQL Command History Dialog

At any time while running the SQL Genie, you may click the History button.

SQL Genie

The SQL Genie creates SQL SELECT statements using Portable SQL.

SQL Genie Columns Tab

The Columns tab of the SQL Genie defines the fields that your SQL SELECT statement will return. To select a field for your report.

SQL Genie Filter Tab

The Filter tab of the SQL Genie defines the expressions that limit the records that your SQL SELECT statement will return.

SQL Genie Having Tab

The Having tab of the SQL Genie filters the records that your SQL SELECT statement will return when you have a GROUP BY clause.

SQL Genie Order Tab

The Order tab of the SQL Genie sequences the records that your SQL SELECT statement will return.

SQL Genie Preview Window

When using the SQL Genie you will see a preview of the records that the current version of the SELECT statement will return. This preview is at the bottom of the dialog box.

SQL Genie Properties Tab

The Properties tab of the SQL Genie defines additional expressions that limit and group the records that your SQL SELECT statement will return.

SQL Genie Tables Tab

The Tables tab of the SQL Genie defines the tables that will provide the data for your report.

SQL Native Syntax Dialog Box

The SQL Native Syntax dialog allows you to see the Portable SQL that you have created in the SQL Genie and the corresponding SQL in the native dialect of any of these databases.

UTF-8 Support in Desktop Applications

In some Desktop Applications built prior to the release of Alpha Anywhere, you will need to check the data returned by the AlphaDAO connection string in your Desktop Application and handle the conversion to UTF-8.

Wildcard Select Dialog

The Wildcard Select dialog provides a way to select additional list items when creating a search string. The search string returns a list of the tables or views whose names match. You can enter letters or wildcard characters into the search string control.

Working with Microsoft Access

In order to read or write to Microsoft Access with AlphaDAO functions, you must have permission to read the database's System Catalog.

Working with Passive-Linked Tables

A Passive-Linked Table is a standard .DBF table. However, it is populated by SQL SELECT statement that retrieves records from a SQL database. It uses the same technology underlying SQL Reporting.