Table A Paradox validity checks Validity check Meaning

Required field Every record in the table must have a value in this field. SQL tables can also use this validity check equivalent to NOT NULL . The values entered in this field must be equal to or greater than the minimum you specify here. The values entered in this field must be less than or equal to the maximum you specify here. The value you specify here is automatically entered in this field. You can replace it with another value. You specify a character string that acts as a template for...

Formatting fields

Delphi provides built-in display and edit format routines and intelligent default formatting for TField components. These routines and formats require no action on the programmer's part. Default formatting conventions are based on settings in the Windows Control Panel. For example, using default Windows settings in the United States, a TFloatField column with the Currency property set to True sets the DisplayFormat property for the value 1234.56 to 1234.56, while the EditFormat is 1234.56. Only...

Using Goto functions

The GoToKey and GoToNearest methods enable an application to search a database table using a key. SetKey puts a table in search mode, more accurately referred to as SetKey state. In SetKey state, assignments indicate values for which to search for in indexed fields. GoToKey then moves the cursor to the first row in the table that matches those field values. For example, the following code could be used in the OnClick event of a button procedure TSearchDemo.SearchExactClick Sender TObject begin...

Figure TDBCheck Box component

Like the other data controls, TDBCheckBox is attached to a specific field in a dataset through its DataSource and DataField properties. Use the Caption property to display a label for the check box on your form. Set the ValueChecked property to a value the control should post to the database if the control is checked when the user moves to another record. By default, this value is set to True, but you can make it any alphanumeric value appropriate to your needs. You can also enter a...

Defining secondary indexes

A secondary index is a field or group of fields other than the key field that can be used to sort the table or to link the table to other tables. Database Desktop enables you to create secondary indexes for Paradox tables. You can use a secondary index to see an alternate view order for a Paradox table. For example, to view the Customer table by City, while keeping the table's key order intact, you can use a secondary index on City to temporarily change the view order of the records. For...

Using Find functions

The Find functions, FindKey and FindNearest provide easy way to search a table. They combine the functionality of SetKey, field assignment, and Goto functions into a single statement. Each of these methods takes a comma-delimited array of values as its argument, where each value corresponds to a column in the underlying table. The values can be literals, variables, null, or nil. If the number of values in an argument is less than the number of columns in the database table, then the remaining...

Figure A TDBRadio Group component

For the current record, if the field associated with a radio group matches one of the strings in the Items or property, that radio button is selected. For example, if three strings, Red, Yellow, and Blue, are listed for Items, and the field for the current record contains the value Blue, then the third button in the group is selected. Note If the field does not match any strings in Items, a radio button may still be selected if the field matches a string in the Values property. If the field for...

Creating applicationspecific aliases

The TDatabase object enables you to create BDE aliases specific to an application. To name the alias, enter a name in the DatabaseName property. Any dataset components can then use the local alias by using the specified DatabaseName. To customize the parameters for a local alias, double-click on the TDatabase component. The Database Properties Editor opens Figure 6.3 Database Properties Editor Figure 6.3 Database Properties Editor This tool enables you to customize application-specific aliases...

Input and output parameters

A stored procedure has a Params array for its input and output parameters similar to a TQuery component. The order of the parameters in the Params array is determined by the stored procedure definition. An application can set the values of input parameters and get the values of output parameters in the array similar to TQuery parameters. You can also use ParamByName to access the parameters by name. If you are not sure of the ordering of the input and output parameters for a stored procedure,...

Navigating and manipulating records with TDBNavigator

TDBNavigator provides users a simple control for navigating through records in a dataset, and for manipulating records. The navigator consists of a series of buttons that enable a user to scroll forward or backward through records one at a time, go to the first record, go to the last record, insert a new record, update an existing record, post data changes, cancel data changes, delete a record, and refresh record display. Next record First record Prior record TDBNavigator component Insert...

Querying table data with QBE

A query is a question you ask about information in one or more tables. In addition to standard SQL queries, Database Desktop enables you to use a technique called query by example QBE to extract and manipulate data in tables. With QBE, you make the query image look like an example of the records you want to search for. The following figure shows a query that gives examples of the fields you want to see and a range of values within one of those fields , and the answer Database Desktop gives....

Building a sample database application Mastapp

This chapter is a tutorial and introduction to building Delphi database applications. Examples show how to perform database tasks using Delphi interactively and by programming in Object Pascal. In each example you build a single form, self-contained and independent of the others. You can save yourself some work by doing the examples in sequence. Several examples use the same basic form as a starting point. Note This material assumes you know how to use Delphi it tells you what to do to perform...

Table Dataaware list box and combo box controls Data controlDescription

TDBListBox Displays a list of items from which a user can update a specific column in the Combines a TDBEdit control with an attached list. The application user can update a specific column in the current data record by typing a value or by choosing a value from the drop-down list. Displays a list of items from which a user can update a column in the current data record. The list of items is looked up in a specific column in another dataset. Combines a TDBEdit control with a dropdown version of...

Figure Two forms

Jg Capital Buenos Aires 1 Place a TTable, a TDataSource, a TButton, three TDBEdit, and three TLabel components on a form. 2 Give the Button the name Detail. 3 Set the Table1's DatabaseName property to the DBDemos alias, and open the COUNTRY Table. 4 Connect DataSource1 to Tablel, then connect each of the DBEdit component's Datasource properties to DataSource1. By performing these steps in this order, you can drop down a list in the DataField property of the data aware controls. 5 Create a...

Displaying multiple views of a table

Applications often need to display two different views of the same dataset. For instance, if you have two forms, and each displays different columns of the same row, you need to find a way to keep these forms synchronized to ensure accurate and up-to-date views of the data in each form. There are two main concepts important to working with multiple views of a table The TDataSource component provides access for multiple forms sharing a single dataset. When you want more than one different view...

Using the ParamByName method

ParamByName is a function that enables an application to assign values to parameters based on their names. Instead of providing the ordinal location of the parameter, you must supply its name. For example, an application could use ParamByName could specify values for the parameters in the preceding example as follows Query2.ParamByName 'Name' .AsString 'Lichtenstein' Query2.ParamByName 'Capital' .AsString 'Vaduz' 420000 These statements would have the same effect as the three previous...

Formatting field values at design time

This example shows how to format a field value by setting the DisplayFormat property at 1 Use the Database Form Expert to build a single-table form that displays all the fields of CUSTOMER.DB. Specify a vertical layout and labels aligned left. For detailed instructions, see page 21. 2 Use the Object Inspector to change the form's Name property to EdCustForm, change the TTable component's Name property to Cust, and change the TTable component's Active property to True. In the form, notice the...

Displaying BLOB graphics with TDBImage

TDBImage is a data-aware component that displays bitmapped graphics contained in J BLOB data fields. It captures BLOB graphics images from a dataset, and stores them - internally in the Windows .DIB format. By default, TDBImage permits a user to edit a graphics image by cutting and pasting to and from the Clipboard, or if you supply an editing method. You can accomplish the same task programmatically by using the CutToClipboard, CopyToClipboard, and PasteFromClipboard methods. To make a...

Building a masterdetail form

The steps in this section show how to use the Database Form Expert to build a form containing two tables a master table and a detail table, linked one-to-many. This form is the basis for the CUSTORD.DFM form in MASTAPP. The master table is CUSTOMER.DB and the detail table is ORDERS.DB. You can access both tables using the MAST alias. The expert links these tables and creates components to display data for one customer at a time, and for each customer, to display many orders. When you use the...

Restructuring tables

Database Desktop enables you to restructure Paradox and dBASE tables to Change field types or sizes Modify table language drivers Restructuring a table is very much like creating it for the first time. You will not be able to restructure a table if Delphi or any other application has the table open. For detailed information on restructuring tables, see the Database Desktop Help choose Helpl ContentslTaskslCreating and RestructuringlRestructuring a Table. Note Restructuring a table may require...

TDBLookup Combo

The TDBLookupCombo component is similar to TDBComboBox, except that it derives its list of values dynamically from a second dataset at run time, and it can display multiple columns in its drop-down list. With this control, you can ensure that users enter valid values into forms by providing an interface from which they can choose values. Here is an example of how a TDBLookupCombo component appears at run time Figure 4.10 TDBLookupCombo component Figure 4.10 TDBLookupCombo component The lookup...

TDBLookup List

TDBLookupList is functionally the same as TDBLookupCombo, but instead of a drop-down list, it displays a scrollable list of the available choices. When the user selects one at run time, the component is assigned that value. Like TDBLookupCombo, the user cannot type in an entry that is not in the list. Here is an example of how a TDBLookupList component appears at run time While navigating through a dataset, a TDBLookupList component highlights the item in the list that corresponds to the value...

Displaying and editing BLOB text with TDBMemo

TDBMemo is a data-aware component similar to the Standard TMemo component that can display binary large object BLOB data. TDBMemo displays multi-line text, and permits a user to enter multi-line text as well. For example, you can use TDBMemo controls to display memo fields from dBASE and Paradox tables and text data contained in BLOB fields. By default, TDBMemo permits a user to edit memo text. To limit the number of characters users can enter into the database memo, use the MaxLength property....

Setting Tfield properties at design time

Because they are invisible, the only way to set the properties of TField components at design time is by using the Fields Editor. The following example shows how to set the properties of a TField component at design time. 1 Use the Database Form Expert to build a single-table form that displays all the fields of CUSTOMER.DB in a grid. For detailed instructions, see page 21. If you re working through these examples in sequence, you can use the form from the previous example and skip to step 5. 2...

Setting the update mode

The UpdateMode property of a dataset determines how Delphi will find records being updated in a SQL database. This property is important in a multi-user environment when users may retrieve the same records and make conflicting changes to them. When a user posts an update, Delphi uses the original values in the record to find the record in the database. This approach is similar to an optimistic locking scheme. UpdateMode specifies which columns Delphi uses to find the record. In SQL terms,...

Symbols

plus sign in property lists 103 operator 177 operator 177 colon in SQL statements 117, 176 lt operator 177 lt gt operator 177 operator 177 gt operator 177 question mark in SQL statements 176 II operator 177 - minus sign in property lists 104 apostrophe , naming conventions 175, 176 abandoning changes 64, 101, 107 Abort procedure 68 AbortOnKeyViol property 92 AbortOnProblem property 92 accessing data 79, 89, 100, 115, 116 at run time 87-88 field values 30, 32 optimizing access 119 remote...