| home / experts / dhtml / column39 |
|

In building a data-bound page the first thing that is required is a data source. In the real world we would use a Data Source Object (DSO) called the Advanced Data Connector (ADC) since it provides access to back-end databases, such as MS SQL Server or Oracle, via a server component and ODBC. However for the purposes of our discussion, we need to build an example that you can experiment with. To do this we will use another DSO called a Tabular Data Control (TDC), which can read data from delimited text files.
The delimited text file contains values (fields) separated by commas, hence the filename extension ".csv", and can be built by hand (using something as simple as NotePad) or exported from MS Excel or Access. Our example delimited text file looks like this and we have named it StaffData.csv:
Dept:string,FirstName:string,LastName:string,Email:string,Telephone:string,Picture:string,About:string Sales,Gareth,Cheeseman,gcheese@abusiness.com,018823654895,gc.jpg,Gareth is our top sales man Sales,Bert,Russell,brussell@abusiness.com,018823654896,none.jpg, Bert backs up Gareth on tricky sales Support,Ernest,Chipset,echipset@abusiness.com,01882365487,none.jpg,Ernest provides after sales support Support,Dilbert,Gantry,dgantry@abusiness.com,01882365488,none.jpg,Dilbert is fast learning the support trade Technical,Shawn,FrontBus,sfrontbus@abusiness.com,01882365490,none.jpg,Shawn is our technical Guru Technical,Roger,Ecma,recma@abusiness.com,01882365491,none.jpg,Roger is our programming expert
The TDC is inserted into the HTML page using the <OBJECT> tag:
<OBJECT ID="tdcStaff"
CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM NAME="DataURL" VALUE="StaffData.csv">
<PARAM NAME="UseHeader" VALUE="True">
<PARAM NAME="TextQualifier" VALUE=",">
</OBJECT>
The DataURL parameter specifies the name and location of the data file. The UseHeader parameter specifies whether the first line of the file contains column names (important for Data Binding). Column names can be followed by a colon (:) and a data type (e.g. String(default), Int, Boolean, Date or Float). Appending a data type tells the TDC to treat the column as that type rather than text when sorting. The TextQualifier parameter specifies the character (delimiter) used to separate the columns.
We now have a DSO, so next we will explore binding the data to HTML elements.
Produced by Ian McArdle and Paul Thomas and
All Rights Reserved. Legal Notices.
Created: Oct 17, 2000
Revised: Oct 17, 2000
URL: http://www.webreference.com/dhtml/column39/4.html