ASTA @ Warp Speed
A Quick Start Tutorial
This document assumes that you have already downloaded
and installed ASTA's evaluation components -- the registered components
work as well! If you have not downloaded the evaluation components, then
get them now!
Starting the ASTA Server
Upon installation of ASTA, you will find in the BDEServer
subdirectory an ASTA server program designed for use with the BDE named
AstaBDEServer.exe. There may be included with your installation other
ASTA servers designed to work with other data access mechanisms, any of
which will suit the purposes of this presentation. Upon starting an ASTA
server program you will be presented with a dialog box, the ASTA Alias
Manager. In order to start the server, leave the User Name and Password
fields empty and simply click the OK button.

Client Side Data Access
The client side of ASTA is designed to take advantage
of the developers existing skill set and to transparently make the switch
from a two-tier model to three-tier. The best demonstration of the power
and ease of use of ASTA is made apparent in the following step-by-step
tutorial.
The first thing to do is to create a new application in
the Delphi/C Builder IDE. When you are presented with the main form of
the project select the ASTA tab on the component palette and drop onto
your main form an AstaClientSocket, and an AstaClientDataSet.
The next task we need to perform has two simple steps
that you will already be familiar with, drop a DataSource component from
the Data Access tab on the form, and follow that with a DBGrid control
from the Data Controls tab of the IDE. As usual, select the DataSource
property of the DBGrid and set it to reference the DataSource component
just dropped on the form. Then select the DataSet property of the DataSource
and set it to reference the AstaClientDataSet component.
Finally, select the TableName property of the AstaClientDataSet,
and choose the Employee table from the drop-down list. Then set AstaClientDataSet
Active property to True.

Eureka! The grid has populated with data at design time.

To complete our task, save, compile and run the application.
When the application starts and you will be presented with the standard
ASTA login prompt. This allows you to specify the server the server that
your application will communicate with. For the purposes of this demo,
simply select the OK button and our work is done. You have just created
a fully functional database application that requires absolutely zero
coding in five minutes flat.

ASTA Database Application Development: No Code Baby
Steps
NoCodeThinClient - Simple Fetch. Write SQL and Go.
The No Code Thin Client tutorial perhaps bests demonstrates
the easy of use and power of ASTA. Upon opening the main form of the project,
you will be presented with a simple form. A DataSource, an AstaClientDataSet
and AstaClientSocket, a DbGrid for display, and a memo with instructions.
As always, start one of the provided ASTA servers, and
select the DbDemos Alias. If the server is running not running locally,
then the address of the AstaClientSocket must be adjusted to reflect the
IP address of the remote machine where the server is running. Otherwise,
the address should be 127.0.0.1, the loop back address for local connections.

ASTA servers, by default listen for and accept TCP/IP
connections on Port 9000. Check to make sure that the Port property of
the AstaClientSocket reflects the current port setting of the server.

Select the AstaClientDataSet component, and select from
the TableName property list, the Employee table. Those readers feeling
extra bold may wish to instead issue a simple SQL statement. Rather than
specifying the TableName property, click the SQL property, and enter the
statement, "Select * From Employee". Set the AstaClientDataSet
Active property to True. Press F9 and you’re done.
Gotcha number one: The dataset is at this point,
Read Only. You cannot edit the data, yet.
Stop the application and return to the Delphi IDE. Set
the DbGrid’s ReadOnly property to False. Click on the EditMode property
of the AstaClientDataSet. You will be presented with a dialog that will
allow you to specify how updates are made to the dataset.

In the Update Method group box, select the Update After
Post option. Select the Employee table, from the Update Table page, and
finally select the EmpNo field from the Prime Key Fields check list box.
You will notice that the status message in red reads, "DataSet is
Editable".
Once again, run the application and you will now be able
to edit the data displayed in the grid.
DataAwareControls - Setting Edit Mode. Edits After Post.
The ASTA components fully support the all of native Delphi
data-aware controls. The DataAwareControls tutorial demonstrates the use
of the DBGrid, DBEdit and the DBNavigator.
Open the tutorial and select the AstaClientDataSet on
the main form. Modify either the TableName property to be Customer or
insert the following SQL statement into the SQL property, "Select
* From Customer". Once again, select the EditMode property of the
AstaClientDataSet to display the property editor. Choose the options,
Update After Post, the Prime Key Field of CustNo, and the customer table
from the Update Table list. Once done, the red status table should display
the message "DataSet is Editable".

Compile and run the application. You will see that the
DBEdit fields track the appropriate row in the dataset as you scroll through
the grid. You may even edit and post changed to the data via the DbNavaigator,
provided the grid ReadOnly property is set to False. Notice that all updates
and inserts to the dataset are instantly reflected, without the need to
manually refresh the dataset.
DataAwareMemo - SQLOptions to Fetch and Update Memos and Blobs.
The DataAwareMemo tutorial demonstrates the ease with
which memos and blobs can be retrieved, updated, or perhaps most importantly,
not fetched. Across a wide area network or the Internet, the transmission
of large binary fields may exact a heavy performance penalty. To address
this, the AstaClientDataSet provide the SQLOptions property which can
be used to control the retrieval of blob and memo fields with the Boolean
soFetchBlobs and soFetchMemos sub-properties. Setting these properties
to false, blob and memo will not automatically be transmitted to the client
from the server when the dataset is requested. Setting them to True will
cause all blobs and memos to be retrieved and editable just like any other
field type.


FetchMemo/FetchBlob - Fetching Memo/Blob on Demand
In a Wide Area Network environment, BLOB fields must be
handled with care -- sending many BLOBs down a slow connection will consume
your bandwidth and severely impact the performance of your application.
These tutorials show you how to handle a memo as a "detail"
field. To see a demonstration with Memo fields, open the FetchMemo tutorial.
Adjusting the AstaClientDataSet SQLOptions subproperty
soFetchMemos to False will prevent the automatic retrieval of memos.
The point being that it may suit your application better to only retrieve
memos when needed. In order to manually retrieve a memo field, the AstaClientSocket
provides the method FetchBlobString(TableName, FieldName, WhereString:
string): string. In the click event of the FetchBlob button on the main
form, you will see the line:
Memo1.Lines.Text := AstaClientDataSet1.FetchBlobString(
'BioLife','Notes','Where Biolife."Species No"='+
AstaClientDataSet1.FieldByName('Species No').AsString);
The first parameter being the name of the table to retrieve
the memo from, the second, the field name, and the third, the conditional
statement which determines which records will be sent. Notice that the
third parameter follows the SQL standard for WHERE clauses, ‘Where BioLife."Species
No" = X’, and in this case, the field ‘Species No’ is in quotation
marks due to the fact that it contains a space.
To see a demonstration of how to retrieve a blob field
manually, open the BlobImage tutorial Here you will see how binary data
stored in a database can be retrieved as a string, then converted to a
stream for use in a graphic control. Notice the difference in the code
this time when fetching a binary object.
procedure TForm1.FetchImageClick(Sender: TObject);
var
St: TStringStream;
begin
// Create a TStringStream to hold the binary data in the returned
string
St := TStringStream.Create(
// Pass the table, the field name & a SQL String
AstaClientDataSet1.FetchBlobString(
'BioLife','Graphic','Where Biolife."Species No"='+
AstaClientDataSet1.FieldByName('Species No').AsString
)
);
try
Image1.Picture.Bitmap.LoadFromStream(St);
finally
St.Free;
end;
end;
The only difference in this example is that we are transferring
the data from a string to a more accessible medium, the TStringStream,
which can be then used with any LoadFromStream method.

BDEMasterDetail - Demonstrating Master Detail Relationships
6. FetchBlobImage-Shows how to fetch a Blob from the server.
You can
also set the SQLOptions to soFetchBlobs and use a dataaware
image
7. ISQL Demo Interactive SQL-Shows how to fetch table
metadata
double click on table names to force SQL select to be
fired.
8. Run Time Edit Changes-remember to "use" AstaDBTools
which contain
the umAfterPost and umCached
9. Transaction Demo showing how to use Cached Updates
10. Sorting. Shows how to do client side sorting.
11. In coded Edits. Shows how to edit with code using
normal VCL calls.
Also shows no flicker requery call ReFireSQL.
12. Packets: shows how to set a server using PersistentSessions
and open
a "cursor" on the server.
13. CloneCursor: shows Clone Cursor Feature
14. ExecParams-Old time sql use
15. ConflictManager- shows how ASTA internally generates
sql
16. ActiveForms- this is sorely in need of an update!
7. Refetch- shows new Refetch On Insert Feature
18. StoredProcedures
19. SuitCase
Copyright @ 2000, ASTA Technology
Group. For more information, contact info@astatech.com
|