RAD Studio for Microsoft .NET
ContentsIndex
PreviousUpNext
Creating an XML File for DB Web Controls

You can use XML files as your data source, particularly if you want to prototype applications without reading from and writing to a database. First you must create the XML file. The DBWebDataSource control provides a powerful way to create the XML file based on real database data. This procedure assumes that you can create a connection to a live database containing the data you want to use.

Note: DB Web Controls (Borland.Data.Web namespace) are being deprecated in 2007. You should use standard Web controls instead.

To create and use an XML file

  1. Create an ASP.NET application using DB Web Controls.
  2. Specify the XML file as a data source for a new ASP.NET application.

To create an ASP.NET application using DBWeb Controls

  1. Choose FileNewASP.NET Web Application for either Delphi for .NET.
  2. Create a database connection and data adapter using the BDP.NET controls or other data adapter controls.
  3. Drag and drop a DBWebDataSource control onto the Designer from the DB Web area of the Tool Palette.
  4. In the XMLFileName property or in the XMLSchemaFile property, specify a new file name of a file that does not yet exist.
  5. Generate a DataSet from the data adapter.
  6. Set the DataSource property of the DBWebDataSource to dataSet1.
  7. Set the Active property of the data adapter to True.
  8. Choose RunRun. This runs the application but also creates the XML file or XSD file and fills it with data from the DataSet.

To specify the XML file as a data source for a new ASP.NET application

  1. Choose FileNewASP.NET Web Application for either Delphi for .NET.
  2. Drag and drop a DataSet component onto the Designer from the Data Components area of the Tool Palette.
  3. Drag and drop a DBWebDataSource control onto the Designer from the DB Web area of the Tool Palette.
  4. Specify the existing XML file name in the XMLFileName property of the DBWebDataSource control.
    Note: If you created an XSD file instead of an XML file, you specify the XSD file name in this step.
  5. Specify the DataSet component in the DataSource property of the DBWebDataSource control.
  6. Drag and drop a DBWebGrid control onto the Designer from the DB Web area of the Tool Palette.
  7. Set the DBDataSource property of the DBWebGrid to the name of the DBWebDataSource
  8. Choose RunRun to display the application. The application pulls data from the DataSet and XML file to fill the DBWebGrid.
Warning: It is possible for you to specify an existing XML file in the XMLFileName property of your DBWebDataSource along with an active BdpDataAdapter and its DataSet. You can run the application and the DBWeb controls will display the data from the XML file. However, this is not the intended use or behavior of the XML capabilities of the DBWebDataSource. Although your XML file data may display properly, the results of an update or any other operations on the data will be unpredictable.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!