Database Register

Script for Listing

The file defined under the database register’s value List, will be called by Consolo when the editor opens the current database register.

 

Request sent to the script by POST:

  • Consolo sends the password set in the configuration as a variable password. Verify it in the script.

 

Response from the script should follow the form:

<?xml version='1.0' encoding='ISO-8859-1'?>
<REGISTER>
  <COLUMN_DEFINITION>
    <COLUMN caption="Id" width="0" />
    <COLUMN caption="caption2" width="x" />
    <COLUMN caption="caption3" width="x" />
    ...
  </COLUMN_DEFINITION>
  <ROW>
    <COLUMN>Id</COLUMN>
    <COLUMN>Value2</COLUMN>
    <COLUMN>Value3</COLUMN>
    ...
  </ROW>
  <ROW>
    <COLUMN>Id</COLUMN>
    <COLUMN>Value2</COLUMN>
    <COLUMN>Value3</COLUMN>
    ...
  </ROW>
  ...
</REGISTER>

 

This means the list can be made up of an unlimited number of columns and rows. In the first node COLUMN_DEFINITION defines what header should be used for every column (caption), and the width of the column (width) in per cent.

After this comes all the rows of the table. Make sure that the number of columns matches the number of columns in COLUMN_DEFINITION.

 

Please note the following:

The initial column should always hold the id-number, that is, the column in the database which will work as identity. Consolo will return this id to the other scripts.

Widths are set in per cent, so make sure the total value equals 100, when adding all column widths. A column can be hidden by typing in 0 for the width.

 

Example

This example illustrates how to create a script for listing in SQL-connected ASP. If you are using another environment on your server, please translate the script to the suitable language.

Start by creating an include, which can be called e.g. db_opendb.asp. You will be including this file later in every script. If for instance, the password to the database is changed at a later point, you will only have to make an update in one place. Here is an example of what db_opendb.asp can look like:

'Opens the database object objConn
Set Connect = Server.CreateObject("ADODB.Connection")< br>Connect.Open"DSN=dsn;UID=user;PWD=password" 

 

Then create a script called e.g. db_test_list.asp. This example lists a member register.

<?xml version='1.0' encoding='ISO-8859-1'?>
<% If Request("password") <> "abc123" Then Response.End %>
<REGISTER>
  <COLUMN_DEFINITION>
    <COLUMN caption="ID" width="0" />
    <COLUMN caption="Member ID" width="32" />
    <COLUMN caption="Name" width="28" />
    <COLUMN caption="Family Name" width="40" />
  </COLUMN_DEFINITION>
<!--#include file="db_opendb.asp"-->
<%
' Retrieve data from database
Set RS = Conn.Execute("SELECT * FROM members ORDER BY
uMemberNumber ASC;" )
While Not RS.Eof
  %>
  <ROW>
    <COLUMN><%=RS("uID")%></COLUMN>
    <COLUMN><%=RS("uMemberNumber")%></COLUMN>
    <COLUMN><%=RS("uFirstName")%></COLUMN>
    <COLUMN><%=RS("uLastName")%></COLUMN>
  </ROW><%
  RS.MoveNext
Wend
' Close database
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
%>
</REGISTER>

Note that:

  • The ID-number has been hidden for the user.
  • The password Consolo sends is verified on line 3.