RAD Studio for Microsoft .NET
ContentsIndex
PreviousUpNext
Database Procedures

This section provides how-to information on developing database applications.

Name 
Description 
You can add new connections to the Data Explorer, which persist as long as the connection object exists. 
You can modify your BDP applications to call the BDP Reconcile Error dialog to handle an update exception (as occurs sometimes when two people are trying to simultaneously update the same row of a database table). 
Once you have a live connection, you can use the Data Explorer to browse database objects. 
You can establish a database connection using AdoDbx Client in several ways. 
You can drag and drop data from the Data Explorer to any forms such as Windows Forms or Web Forms, and Global.asax files. to populate datasets and quickly build a database project. This allows you to automatically hook up database components to your project and eliminates the need to provide a connection string, which can be prone to errors if entered manually. 
Using the TableMappings property, you can map columns between a data source and an in-memory dataset. This allows you to use different, often more descriptive names for your dataset columns. You can also map a column in a database table to a column in the dataset different from that which is selected by default. The TableMappings property also allows you to create a dataset that contains fewer or more columns than those retrieved from the database schema. 
You can write, edit, and execute SQL in an SQL Window, which is available from within the Data Explorer
Whenever you perform any type of comparison function between a data source and an in-memory data representation, there is potential for error. Errors can occur when a data source and its corresponding dataset do not share uniform numbers of columns, or when column types in a data source do not correspond to the column types in the dataset. In addition, other, internal errors can occur for which there is no designtime workaround. You can use both the MissingMappingAction property and the MissingSchemaAction property to respond to errors in your table mapping operations. Use the MissingMappingAction when you want to specify... more 
The DataExplorer makes it easy to migrate data from one database to another, and even between providers. The DataExplorer lets you quickly copy a table from one database and paste it into another database. Both the structure and the data for the table or tables is migrated.
Data migration is supported by the BdpCopyTable class, which is available as a designtime component from the Tool Palette. You can use this component to programmatically migrate data.
Note: The BdpCopyTable class does not copy foreign keys or dependent objects.
 
You can modify connections in a variety of ways from the Data Explorer
The basic elements of a connection string tend to be the same from one database type to another. However, each database type supports slightly different connection string syntax. This topic addresses those differences. 
RAD Studio supports multi-table resolution with BDP.NET. Specifically, the DataSync and DataHub components are designed to provide and resolve a .NET DataSet from multiple heterogeneous data sources. In addition, these components support the display of live data at designtime, and provide and resolve master-detail data by generating optimal SQL for resolving to BDP data sources.
The DataHub acts as a conduit between a DataSet and a DataSync. The DataPort property for a DataHub can be set to any IDataProvider implementation. DataSync implements IDataProvider and has a Providers collection that can contain any .NET data provider that implements IDbDataAdapter. The GetData... more 
The following procedures describe a simple application that allows you to pass a parameter value at runtime to a DataSet. Parameters allow you to create applications at design time without knowing specifically what data the user will enter at runtime. This example process assumes that you already have your sample Interbase Employee database set up and connected. For purposes of illustration, this example uses the default connector IBConn1, which is set to a standard location. Your database location may differ. 
CodeGear RAD Studio provides a tool that enables communication between a data source and a dataset. You can use the Data Adapter Preview to specify what data to move into and out of the dataset either in the form of SQL statements or stored procedures that are invoked to read or write a database. 
In order to create a DataSet, your BdpDataAdapter needs to have at least a SQL Select statement defined for the CommandText property. This statement, once built, appears as the CommandText of the BdpCommand object for the BdpDataAdapter. You can enter this Select statement manually, or you can use the Command Text Editor to construct the statement, along with Update, Insert, and Delete statements, using a simple point-and-click mechanism. Using this method, once you have a connection to a live data source, you will be able to see the names of tables and columns in the Command Text Editor. You... more 
The Data Adapter contains, at a minimum, a SQL Select statement of the SELECT command property. You can enter this statement yourself, or using the Data Adapter designer you can construct the Select, along with the Update, Insert, and Delete statements. The BdpCommandBuilder constructs the Update, Insert, and Delete statements based on the tables and columns you have selected. The Data Adapter designer uses a live connection to retrieve metadata from which you can build the appropriate SQL statements for manipulating the data you want to move from a DataSet back into your database. 
Each connection object can support multiple named connections. These connections can represent connections to multiple databases and database types. 
The standard DataSet provides an in-memory representation of one or more tables or views retrieved from a connected data source. Because of the level of indirection used in coding the underlying data structure, you are only able to see the column names from your data source at runtime. When you generate a DataSet, it retrieves everything you specified in your Select statement in the Data Adapter Configuration dialog. You can limit your columns by changing the Select statement and creating a new DataSet. 
Typed DataSets provide certain advantages over standard DataSets. For one thing, they are derived from an XML hierarchy of the target database table. The XML file containing the DataSet description allows the system to provide extensive code-completion capabilities not available when using standard DataSets. Strong typing of DataSet methods, properties, and events allows compile-time type checking, and can provide a performance improvement in some applications. 
This procedure tells how to use the dbExpress driver framework to connect to a database and read its records. In the sample code, the dbExpress ini files contain all the information about the particular database connection, such as driver, user name, password, and so on. 
Data remoting is fundamental to developing distributed database applications. The .NET remoting technology provides a flexible and extensible framework for interprocess communication. With .NET remoting you can interact with objects in different application domains, in different processes running on the same machine, or in different machines on a network.
Using the RemoteServer and RemoteConnection components, you can easily migrate a client/server application that uses DataHub and DataSync components to a multi-tier DataSet remoting application. RemoteServer implements IDataService and publishes itself as a singleton server activated object (SAO). On the client side, the RemoteConnection properties form the URL for connecting to... more 
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!