Sending commands to the server

All database connection components except TIBDatabase let you execute SQL statements on the associated server by calling the Execute method. Although Execute can return a cursor when the statement is a SELECT statement, this use is not recommended. The preferred method for executing statements that return data is to use a dataset. The Execute method is very convenient for executing simple SQL statements that do not return any records. Such statements include Data Definition Language DDL...

Using implements for delegation

Many classes have properties that are subobjects. You can also use interfaces as property types. When a property is of an interface type or a class type that implements the methods of an interface you can use the keyword implements to specify that the methods of that interface are delegated to the object or interface reference which is the value of the property. The delegate only needs to provide implementation for the methods. It does not have to declare the interface support. The class...

Transaction attributes

Every transactional object has a transaction attribute that is recorded in the MTS catalog or that is registered with COM . Delphi lets you set the transaction attribute at design time using the Transactional Object wizard or the Type Library editor. Each transaction attribute can be set to these settings Objects must execute within the scope of a transaction. When a new object is created, its object context inherits the transaction from the context of the client. If the client does not have a...

Creating an Active Server Object

An Active Server Object is an Automation object that has access to information about the entire ASP application and the HTTP messages it uses to communicate with browsers. It descends from TASPObject or TASPMTSObject which is in turn a descendant of TAutoObject , and supports Automation protocols, exposing itself for other applications or the script in the Active Server page to use. You create an Active Server Object using the Active Server Object wizard. Your Active Server Object project can...

Cleaning up the example

After completing this example, you will want to restore Delphi to its original form. 1 Delete the objects on this Servers page Choose Component Install Packages. From the list, select the WordExample package and click remove. Click Yes to the message box asking for confirmation. Exit the Install Packages dialog by clicking OK. 2 Return the Microsoft Office Automation Server Wrapper Components package Choose Component Install Packages. In the resulting dialog, choose dclaxserver70.bpl,...

Mapping between XML nodes and data packet fields

XML provides a text-based way to store or describe structured data. Datasets provide another way to store and describe structured data. To convert an XML document into a dataset, therefore, you must identify the correspondences between the nodes in an XML document and the fields in a dataset. Consider, for example, an XML document that represents a set of email messages. It might look like the following containing a single message lt xml version 1.0 standalone yes gt lt email gt lt head gt lt...

Web App Debugger

The server types mentioned above have their advantages and disadvantages for production environments, but none of them is well-suited for debugging. Deploying your application and configuring the debugger can make Web server application debugging far more tedious than debugging other application types. Fortunately, Web server application debugging doesn't need to be that complicated. The IDE includes a Web App Debugger which makes debugging simple. The Web App Debugger acts like a Web server on...

Using the as operator with interfaces

Classes that implement interfaces can use the as operator for dynamic binding on the interface. In the following example, procedure PaintObjects P TInterfacedObject var X IPaint the variable P of type TInterfacedObject, can be assigned to the variable X, which is an IPaint interface reference. Dynamic binding makes this assignment possible. For this assignment, the compiler generates code to call the Querylnterface method of P's IInterface interface. This is because the compiler cannot tell...

Events when establishing a connection

In addition to the BeforeConnect and AfterConnect events that are common to all database connection components, TADOConnection also generates an OnWillConnect and OnConnectComplete event when establishing a connection. These events occur after the BeforeConnect event. OnWillConnect occurs before the ADO provider establishes a connection. It lets you make last minute changes to the connection string, provide a user name and password if you are handling your own login support, force an...

Debugging multithreaded applications

When debugging multi-threaded applications, it can be confusing trying to keep track of the status of all the threads that are executing simultaneously, or even to determine which thread is executing when you stop at a breakpoint. You can use the Thread Status box to help you keep track of and manipulate all the threads in your application. To display the Thread status box, choose View I Debug Windows I Threads from the main menu. When a debug event occurs breakpoint, exception, paused , the...

Creating groups of tool buttons

To create a group of tool buttons, select the buttons you want to associate and set their Style property to tbsCheck then set their Grouped property to True. Selecting a grouped tool button causes other buttons in the group to pop up, which is helpful to represent a set of mutually exclusive choices. Any unbroken sequence of adjacent tool buttons with Style set to tbsCheck and Grouped set to True forms a single group. To break up a group of tool buttons, separate the buttons with any of the...

Using stored proceduretype datasets

How your application uses a stored procedure depends on how the stored procedure was coded, whether and how it returns data, the specific database server used, or a combination of these factors. In general terms, to access a stored procedure on a server, an application must 1 Place the appropriate dataset component in a data module or on a form, and set its Name property to a unique value appropriate to your application. 2 Identify the database server that defines the stored procedure. Each...

Renaming a file

To change a file name, use the RenameFile function function RenameFile const OldFileName, NewFileName string Boolean RenameFile changes a file name, identified by OldFileName, to the name specified by NewFileName. If the operation succeeds, RenameFile returns True. If it cannot rename the file for example, if a file called NewFileName already exists , RenameFile returns False. For example if not RenameFile 'OLDNAME.TXT','NEWNAME.TXT' then ErrorMsg 'Error renaming file ' You cannot rename move a...

Listing stored procedure parameters

To get a list of all parameters defined for a specific stored procedure, use the GetProcedureParams method. GetProcedureParams fills a TList object with pointers to parameter description records, where each record describes a parameter of a specified stored procedure, including its name, index, parameter type, field type, and so on. GetProcedureParams takes two parameters the name of the stored procedure, and an already-existing TList object to fill List1 To convert the parameter descriptions...

Opening a connection using TDatabase

As with all database connection components, to connect to a database using TDatabase, you set the Connected property to True or call the Open method. This process is described in Connecting to a database server on page 23-3. Once a database connection is established the connection is maintained as long as there is at least one active dataset. When there are no more active datasets, the connection is dropped unless the database component's KeepConnection property is True. When you connect to a...

Using brushes

The Brush property of a canvas controls the way you fill areas, including the interior of shapes. Filling an area with a brush is a way of changing a large number of adjacent pixels in a specified way. The brush has three properties you can manipulate Color property changes the fill color. Style property changes the brush style. Bitmap property uses a bitmap as a brush pattern. The values of these properties determine the way the canvas fills shapes or other areas. By default, every brush...

Communicating with the client dataset

All communication between a provider and a client dataset or XML broker takes place through an IAppServer interface. If the provider is in the same application as the client, this interface is implemented by a hidden object generated automatically for you, or by a TLocalConnection component. If the provider is part of a multi-tiered application, this is the interface for the application server's remote data module or in the case of a SOAP server an interface generated by the connection...

Using nested detail tables

A nested table is a detail dataset that is the value of a single dataset field in another master dataset. For datasets that represent server data, a nested detail dataset can only be used for a dataset field on the server. TClientDataSet components do not represent server data, but they can also contain dataset fields if you create a dataset for them that contains nested details, or if they receive data from a provider that is linked to the master table of a master detail relationship. Note For...

Creating most recently used MRU lists

A most recently used list MRU reflects the user's most recently accessed files in a specific application. Using action bands, you can code MRU lists in your applications. When building MRUs for your applications, it is important not to hard code references to specific numerical indexes into the Action Manager's ActionBars property. At runtime, the user may change the order of items or even delete them from the action bands, which in turn will change the numerical ordering of the index. Instead...

Implementing IInterface

Just as all objects descend, directly or indirectly, from TObject, all interfaces derive from the IInterface interface. IInterface provides for dynamic querying and lifetime management of the interface. This is established in the three IInterface methods QueryInterface dynamically queries a given object to obtain interface references for the interfaces that the object supports. _AddRef is a reference counting method that increments the count each time a call to QueryInterface succeeds. While...

Determining dataset states

The state or mode of a dataset determines what can be done to its data. For example, when a dataset is closed, its state is dsInactive, meaning that nothing can be done to its data. At runtime, you can examine a dataset's read-only State property to determine its current state. The following table summarizes possible values for the State property and what they mean Table 24.1 Values for the dataset State property Table 24.1 Values for the dataset State property DataSet closed. Its data is...

Importing data from another table

You can use a table component's BatchMove method to import data from another table. BatchMove can Copy records from another table into this table. Update records in this table that occur in another table. Append records from another table to the end of this table. Delete records in this table that occur in another table. BatchMove takes two parameters the name of the table from which to import data, and a mode specification that determines which import operation to perform. Table 26.3 describes...

Using transactional data modules

You can write an application server that takes advantage of special services for distributed applications that are supplied by COM under Windows 2000 and later or MTS before Windows 2000 . To do so, create a transactional data module instead of an ordinary remote data module. When you use a transactional data module, your application can take advantage of the following special services Security. COM or MTS provides role-based security for your application server. Clients are assigned roles,...

Using Web Services

Web Services are self-contained modular applications that can be published and invoked over the Internet. Web Services provide well-defined interfaces that describe the services provided. Unlike Web server applications that generate Web pages for client browsers, Web Services are not designed for direct human interaction. Rather, they are accessed programmatically by client applications. Web Services are designed to allow a loose coupling between client and server. That is, server...

Common properties and methods of Canvas

Table 12.2 lists the commonly used properties of the Canvas object. For a complete list of properties and methods, see the TCanvas component in online Help. Table 12.2 Common properties of the Canvas object Font Specifies the font to use when writing text on the image. Set the properties of the TFont object to specify the font face, color, size, and style of the font. Brush Determines the color and pattern the canvas uses for filling graphical shapes and backgrounds. Set the properties of the...

Creating a grid that contains other dataaware controls

A TDBCtrlGrid control displays multiple fields in multiple records in a tabular grid format. Each cell in a grid displays multiple fields from a single row. To use a database control grid 1 Place a database control grid on a form. 2 Set the grid's DataSource property to the name of a data source. 3 Place individual data controls within the design cell for the grid. The design cell for the grid is the top or leftmost cell in the grid, and is the only cell into which you can place other controls....

Registering nonscalar types

Before an invokable interface can use any types other than the built-in scalar types listed in Using nonscalar types in invokable interfaces on page 38-4, the application must register the type with the remotable type registry. To access the remotable type registry, you must add the InvokeRegistry unit to your uses clause. This unit declares a global function, RemTypeRegistry, which returns a reference to the remotable type registry. Note On clients, the code to register types with the...

Obtaining an editable result set

To request a result set that users can edit in data-aware controls, set a query component's RequestLive property to True. Setting RequestLive to True does not guarantee a live result set, but the BDE attempts to honor the request whenever possible. There are some restrictions on live result set requests, depending on whether the query uses the local SQL parser or a server's SQL parser. Queries where table names are preceded by a BDE database alias as in heterogeneous queries and queries...

Calling the interface of a SOAPbased server

If you are using SOAP, you can't use the AppServer property. Instead, you must obtain the server's interface by calling the GetSOAPServer method. Before you call GetSOAPServer, however, you must take the following steps Your client application must include the definition of the application server's interface and register it with the invocation registry. You can add the definition of this interface to your client application by referencing a WSDL document that describes the interface you want to...

Exposing events to clients

There are two types of events that a COM object can generate traditional events and COM events require that you create a separate event object using the event object wizard and add code to call that event object from your server object. For more information about generating COM events, see Generating events under COM on page 46-19. You can use the wizard to handle much of the work in generating traditional events. This process is described below. Note The COM object wizard does not generate...

Creating international applications

This chapter discusses guidelines for writing applications that you plan to distribute to an international market. By planning ahead, you can reduce the amount of time and code necessary to make your application function in its foreign market as well as in its domestic market. Internationalization and localization To create an application that you can distribute to foreign markets, there are two major steps that need to be performed If your edition includes the Translation Tools, you can use...

Dispatching requests and responses

One reason to use WebSnap for your Web server application development is that WebSnap components automatically handle HTML requests and responses. Instead of writing event handlers for common page transfer chores, you can focus your efforts on your business logic and server design. Still, it can be helpful to understand how WebSnap applications handle HTML requests and responses. This section gives you an overview of that process. Before handling any requests, the Web application module...

Creating custom exception classes for Web Services

When your Web Service application raises an exception in the course of trying to execute a SOAP request, it automatically encodes information about that exception in a SOAP fault packet, which it returns instead of the results of the method call. The client application then raises the exception. By default, the client application raises a generic exception of type ERemotableExceptionwith the information from the SOAP fault packet. You can transmit additional, application-specific information by...

Specifying a batch move mode

The Mode property specifies the operation a batch move component performs Table 26.8 Batch move modes Append records to the destination table. Update records in the destination table with matching records from the source table. Updating is based on the current index of the destination table. If a matching record exists in the destination table, update it. Otherwise, append records to the destination table. Create the destination table based on the structure of the source table. If the...

Specifying a connection using sockets

You can establish a connection to the application server using sockets from any machine that has a TCP IP address. This method has the advantage of being applicable to more machines, but does not provide for using any security protocols. When using sockets, include a TSocketConnection component for connecting to the application server. TSocketConnection identifies the server machine using the IP Address or host name of the server system, and the port number of the socket dispatcher program...

Choosing navigator buttons to display

When you first place a TDBNavigator on a form at design time, all its buttons are visible. You can use the VisibleButtons property to turn off buttons you do not want to use on a form. For example, when working with a unidirectional dataset, only the First, Next, and Refresh buttons are meaningful. On a form that is intended for browsing rather than editing, you might want to disable the Edit, Insert, Delete, Post, and Cancel buttons. Hiding and showing navigator buttons at design time The...

Passing object references

Note Information on passing object references applies only to MTS, not COM . This mechanism is needed under MTS because it is necessary to ensure that all pointers to objects running under MTS are routed through interceptors. Because interceptors are built into COM , you do not need to pass object references. Under MTS, you can pass object references, for example, for use as a callback only in the following ways Through return from an object creation interface, such as CoCreateInstance or its...

Adding new records

A dataset must be in dsInsert mode before an application can add new records. In code, you can use the Insert or Append methods to put a dataset into dsInsert mode if the read-only CanModify property for the dataset is True. When a dataset transitions to dsInsert mode, it first receives a BeforeInsert event. After the transition to insert mode is successfully completed, the dataset receives first an OnNewRecord event hand then an AfterInsert event. You can use these events, for example, to...

Enabling simple data binding with the type library

With simple data binding, you can bind a property of your ActiveX control to a field in a database. To do this, the ActiveX control must communicate with its host application about what value represents field data and when it changes. You enable this communication by setting the property's binding flags using the Type Library editor. By marking a property bindable, when a user modifies the property such as a field in a database , the control notifies its container the client host application...

Resource pooling

Since idle system resources are freed during a deactivation, the freed resources are available to other server objects. For example, a database connection that is no longer used by a server object can be reused by another client. This is called resource pooling. Pooled resources are managed by a resource dispenser. A resource dispenser caches resources, so that transactional objects that are installed together can share them. The resource dispenser also manages nondurable shared state...

Using the WSDL importer

To use the WSDL importer, choose Filel Newl Other, and on the WebServices page double-click the icon labeled WSDL importer. In the dialog that appears, specify the file name of a WSDL document or XML file or provide the URL where that document is published. Note If you do not know the URL for the WSDL document you want to import, you can browse for one by clicking the button labeled Search UDDI. This launches the UDDI browser, which is described in Browsing for Business services on page 38-14....

Supporting state information in remote data modules

The IAppServer interface, which client datasets use to communicate with providers on the application server, is mostly stateless. When an application is stateless, it does not remember anything that happened in previous calls by the client. This stateless quality is useful if you are pooling database connections in a transactional data module, because your application server does not need to distinguish between database connections for persistent information such as record currency. Similarly,...

About Web Broker and WebSnap

Part of the function of any application is to make data accessible to the user. In a standard application you accomplish this by creating traditional front end elements, like dialogs and scrolling windows. Developers can specify the exact layout of these objects using familiar form design tools. Web server applications must be designed differently, however. All information passed to users must be in the form of HTML pages which are transferred through HTTP. Pages are generally interpreted on...

using IntraWeb

IntraWeb is a tool which simplifies Web server application development. You can use IntraWeb to build Web server applications exactly the same way you would build traditional GUI applications, using forms. You can write all of your business logic in the Delphi language IntraWeb will automatically convert program elements to script or HTML when necessary. You can use IntraWeb in any of the following modes 1 Standalone mode. IntraWeb uses its own application object type to handle program...

Specifying a dBASE index file

For most servers, you use the methods common to all table type datasets to specify an index. These methods are described in Sorting records with indexes on page 24-26. For dBASE tables that use non-production index files or dBASE III PLUS-style indexes .NDX , however, you must use the IndexFiles and IndexName properties instead. Set the IndexFiles property to the name of the non-production index file or list the .NDX files. Then, specify one index in the IndexName property to have it actively...

Automation compatible types

Function result and parameter types of the methods declared in dual and dispatch interfaces and interfaces that you mark as OLE Automation must be Automation-compatible types. The following types are OLE Automation-compatible The predefined valid types such as Smallint, Integer, Single, Double, WideString. For a complete list, see Valid types on page 41-12. Enumeration types defined in a type library. OLE Automation-compatible enumeration types are stored as 32-bit values and are treated as...

Determining the source of data

When you use a provider component, you must specify the source it uses to get the data it assembles into data packets. Depending on your version of Delphi, you can specify the source as one of the following To provide the data from a dataset, use TDataSetProvider. To provide the data from an XML document, use TXMLTransformProvider. Using a dataset as the source of the data If the provider is a dataset provider TDataSetProvider , set the DataSet property of the provider to indicate the source...

Combo boxes

A combo box TComboBox combines an edit box with a scrollable list. When users enter data into the control by typing or selecting from the list the value of the Text property changes. If AutoComplete is enabled, the application looks for and displays the closest match in the list as the user types the data. Three types of combo boxes are standard, drop-down the default , and drop-down list. 1 Set the Style property to select the type of combo box you need Use csDropDown to create an edit box...

Working with record sets

The Recordset property provides direct access to the ADO recordset object underlying the dataset component. Using this object, it is possible to access properties and call methods of the recordset object from an application. Use of Recordset to directly access the underlying ADO recordset object requires a good working knowledge of ADO objects in general and the ADO recordset object in specific. Using the recordset object directly is not recommended unless you are familiar with recordset object...

Installing transactional objects

MTS applications consist of a group of in-process MTS objects running in a single instance of the MTS executive EXE . A group of COM objects that all run in the same process is called a package. A single machine can be running several different packages, where each package is running within a separate MTS EXE. Under COM , you work with a similar group, called a COM application. In a COM application, the objects need not be in-process, and there is no separate runtime environment. You can group...