344 MGraphics.ru - SSI - Функция Odbc
Уроки photoshopa


SSI

Функция Odbc

Условия перепечатки материалов

Рейтинг статьи: 11111
Проголосовало 2 человека.
Оцените статью:

odbc

Notice! Due to some problems with the MS ODBC drivers we are phasing out the support of the SSI+ ODBC tags. To impliment ODBC with WebQuest we are using CScript with our WQODBC.DLL. For more information on CScript and ODBC, check out the Guestbook tutorial. The SSI+ ODBC tags will not exist in WebQuest 3.0.

The odbc tag provides for querying and updating odbc databases. Four variables are defined for the odbc token; 'debug', 'connect', 'statement', and 'format'.

'debug' variable

The debug variable is used to set the SSI+ engine into debug mode. Debug mode provides diagnostics of a highly detailed nature from both the SSI engine itself and the local ODBC engine. Debug messages appear on the returned HTML document at the position at which the errors occur. The debug variable should be used only for development and must be removed before production. When the debug variable is present a warning message will appear indicating it's presence, this message is benign and will not affect any other aspect of the SSI+ engine. The format of the debug variable is : 'debug='"<debugstring>"' where;

  • <debugstring> is any string and is reserved for future use.



'connect' variable

The connect variable is used to connect to a pre-existing odbc data source, to allow for subsequent statement tag operations on that data source. The format of the connect variable is 'connect="'<datasource>','<username>','<password>'"'where ;

  • <datasource> is the name odbc data source as defined on the local system in the odbc configuration utility. CAUTION! the account under which the server is run must be granted permission to access the data source.
  • <user name> is the name which to log into the data source.
  • <password> is the password with which to access the data source.

Example. To connect to a data source called 'odbcsht' as user 'dufus' and password 'dorkboy', one would use the following statement: <!--#odbc connect="odbcsht,dufus,dorkboy"-->.

'statement' variable

The statement variable is used to submit a Transact SQL statement to the odbc data source. The format of a statement variable is as follows: 'statement="'<SQLStatement>'"',where:

  • <SQL Statement> is any Transact SQL statement as defined in odbc and SQL reference text and help files.

Example. Suppose one wanted to query the 'CUSTOMERS' table from the above connected 'odbcsht' database to return all rows and display each row on a separate line. One may use the following sequence of statements:

  1. Connect to the database with a connect token as described above.
  2. Setup the output format with a statement token as described below.
  3. Execute the query: <!--#odbc statement="SELECT NAME, AGE, VISCOSITY FROM CUSTOMERS ORDER BY 3, 2, 1" -->
  4. Each row of the database will the be inserted into the HTML page per the format statement as demonstrated below.



'format' variable

The format variable is used to provide a template for the format of data that is returned from and odbc query. Use this variable to set up the appearance of data that will be returned from subsequent statement tag operations that return data from a database (i.e. the SQL statement 'SELECT'). The format of the format variable is 'format="'<cprintfstatement>'"'where;

  • <cprintfstatement> is a standard C language printf format string with the restriction of only allowing string (%s) insertions. The user is referred to any C language text for a description of this format. The number of instances of %s must be equal to the number of fields selected in a the subsequent SQL SELECT statement token.

Example. Suppose one wanted to query the 'CUSTOMERS' table from the above connected 'odbcsht' database to display the columns 'name', 'age', and 'viscosity' with each row on a separate line. One may use the following sequence of statements:

  1. Connect to the database with a connect token as described above.
  2. Setup the output format: <!--#obdc format="<P>Thecustomer's name is %s, and he is %s years old, he prefers a motor oil with SPF %s viscosity" -->.
  3. Execute the query with a statement token as described above.
  4. Each row of the database will the be inserted into the HTML page per the format statement. For example if the database has 3 rows the HTML output would look something like this:
  • Customer's name is Conan, and he is 29 years old, he prefers a motor oil with SPF 15 viscosity
  • Customer's name is Kevin, and he is 45 years old, he prefers a motor oil with SPF 30 viscosity
  • Customer's name is Alan, and he is 43 years old, he prefers a motor oil with SPF 50 viscosity

Разместил: Vulko
Опубликовано: 21.06.2004
Статья "SSI - Функция Odbc" прочтена 7788 раз.





Последние новости