ASA Getting Started
Microsoft Visual Basic Quick Start
This brief tutorial is based on Visual Basic 6.0. The complete application can be found in the Visual Basic project Samples\ASA\VBStarter\ASAStarter.vbp.
Visual Basic provides several data access technologies. In this tutorial, we use the Microsoft ADO Data Control with the Adaptive Server Anywhere OLE DB provider to access the Adaptive Server Anywhere sample database from Visual Basic.
To develop a database application with Visual Basic
Start Visual Basic, choosing a Standard Executable project.
Add the Microsoft ADO Data Control 6.0 to your tool palette:
From the Project menu, choose Components.
Select the Microsoft ADO Data Control 6.0 component from the list.
Click OK to add the control to the palette.
Add the ADO Data Control to the form, as follows:
Configure the ADO Data Control:
Property | Value |
---|---|
ConnectionString | Provider=ASAPROV;DSN=ASA 9.0 Sample |
CursorLocation | 2 - asUseServer |
CursorType | 1 - adOpenKeyset |
RecordSource | SELECT * FROM EMPLOYEE |
The ConnectionString uses the Adaptive Server Anywhere OLE DB Provider (ASAProv) to connect to the ASA 9.0 Sample data source. The cursor settings take advantage of Adaptive Server Anywhere cursors rather than using the client-side cursors.
Add two text boxes to the form, as follows:
Bind the text boxes to the ADO Data Control:
Set the DataSource property for each to be Adodc1.
Set the DataField property for the left-hand text box to emp_fname, which is the column holding the employee's first name.
Set the DataField property for the right-hand text box to emp_lname, which is the column holding the employee's last name.
Save the project.
Run the sample:
Choose Run
The application connects to the Adaptive Server Anywhere sample database and puts the name of the first employee in the text boxes, as follows:
You can use the buttons on the ADO Data Control to scroll through the rows of the result set.
You have now created a simple Visual Basic application that works with Adaptive Server Anywhere.