MAIN PAGE |
Consider an MS Accessâ Database named 'GridTest'. To create an on-line editable grid for the database, it must be specified in the System DSN of the Server running iASP and a web server (e.g. Apache etc.). The procedure is as follows:
NOTE: The System DSN stores information about how to access databases. The System DSN is available to all users of the computer while the User DSN is available only to the specific user, and the File DSN can be shared by users who have the same database drivers installed.
Departments:
Employees:
Field Name Field Type ID AutoGenerated Phone Text Name Text
Note: All the sample asp pages and the GIF files included (i.e. edit.gif, delete.gif, add.gif, up.gif, down.gif, forward.gif, backward.gif, cancel.gif, save.gif) must be copied to the publishing directory of the Web Server being used. Otherwise the samples will not function properly.
Field Name Field Type ID AutoGenerated Department ID Number (Long) First Name Text Last Name Text Salary Currency Marital Status Number (Long) Fully Vested Number (Byte)
Sample Code:
<%
Set Grid = Server.CreateObject("Persits.AspGrid")
Grid.FileName = "Sample.asp"
Grid.Connect "sun.jdbc.odbc.JdbcOdbcDriver","jdbc:Odbc:GridTest", "", ""
Grid.SQL = "select id, name, phone from Departments"
Grid.Cols(1).Hidden = True
%><HTML>
<BODY><% Grid.Display %>
<% Grid.Disconnect %></BODY>
</HTML>
The Grid displayed for the above
sample code would be as follows:
In the above Sample code the line Set Grid =Server.CreateObject("Persits.AspGrid") simply creates an instance of the iASP_Grid object.
The line Grid.FileName = "Sample.asp" specifies the name of the file in which the above script is saved. Here we have assumed the name is Sample.asp. iASP_Grid will use this property to correctly generate the ACTION attributes of all FORMs.
Grid.Connect "sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:Odbc:GridTest", "", "" specifies the Jdbc-Odbc driver, a data source name (DSN), user id and password. In this case the DSN is "GridTest". Assuming that no security is used, the user id and password are left blank.
The line Grid.SQL = "select id,
name, phone from Departments" specifies the SQL SELECT statement that
the grid is based on. It contains three fields of the table although only
two of them, name and phone are visible.
NOTE: There must be an IDENTITY column (i.e. AutoNumber column or a PrimaryKey column in the specified table. In order for iASP_Grid to work, the identity column must be the first field specified in the main SELECT statement's list of fields.Due to Grid.Cols(1).Hidden = True the first column of the grid i.e. id is not visible. Column numbering is according to the order in the SELECT statement. The method Cols(i) returns a corresponding Column object representing a single column in the grid.
Grid.Display does most of the component's work. It carries out all user requests such as Add New or Save, by opening the recordset, reading data from the table, and generating the actual Table or Form requested.
Grid.Disconnect terminates the connection to the datasource established through Grid.Connect.
The following samples demonstrate step by step how to build powerful iASP_Grid based Web applications.
If you require technical support please send complete details about the problem you are having to support@halcyonsoft.com.
Copyright 1998-2000, Halcyon
Software Inc. All rights reserved.