|
This example shows the use of the
VbsDbGetOutputFieldValue method.
It is a typical table subtable example:
when an order is selected in the main table, the corresponding order detail is shown
in the subtable.
The framework is extremely scalable: note that the extension to two or more subtables
is trivial, and it is also immediate to build cascading subtables (subtables of subtables).
Many of the lines used in this example are not necessary to set up the table/subtable
scenario: they are added to improve the layout and to help the
visitor in data manipulating. To understand how easily table-subtable is implemented, just
follow the lngOrderId variable.
  |
1 |
10248
|
8/4/1994
|
  |
2 |
10249
|
8/5/1994
|
  |
3 |
10250
|
8/8/1994
|
  |
4 |
10251
|
8/8/1994
|
  |
5 |
10252
|
8/9/1994
|
|
|
  |
10248
|
11
|
14
|
12
|
0
|
  |
10248
|
42
|
9
|
10
|
0
|
  |
10248
|
72
|
34.5
|
5
|
0
|
|
|
This is the code implementing the example:
<!--#include file="VBSdb/inc.asp"-->
<%
VbsDbNew objVbsDbOrders
objVbsDbOrders( "GlobalId" ) = "Orders"
objVbsDbOrders( "MdbPath" ) = constMdbPathForExamples
objVbsDbOrders( "Sql" ) = "select * from Orders"
objVbsDbOrders( "ViewMode" ) = "Grid"
objVbsDbOrders( "ViewNavigationButtons" ) = "first;prev;next;last"
objVbsDbOrders( "ViewNavigationPosition" ) = "Top"
objVbsDbOrders( "GridFields" ) = "OrderId;OrderDate"
objVbsDbOrders( "GridUpdateButtons" ) = true
objVbsDbOrders( "GridDeleteButtons" ) = true
objVbsDbOrders( "GlobalImageDir" ) = "VBSdb/images"
objVbsDbOrders( "EditTableName" ) = "Orders"
objVbsDbOrders( "EditKeyFields" ) = "OrderID"
VbsDb objVbsDbOrders
lngOrderId = VbsDbGetOutputFieldValue( "OrderId" , objVbsDbOrders )
VbsDbClose objVbsDbOrders
VbsDbNew objVbsDbOrderDetails
objVbsDbOrderDetails( "GlobalId" ) = "OrderDetails"
objVbsDbOrderDetails( "MdbPath" ) = "data/nwind.mdb"
objVbsDbOrderDetails( "Sql" ) = "select * from [Order Details] where OrderId=" & lngOrderId
objVbsDbOrderDetails( "GridShowIndex" ) = false
objVbsDbOrderDetails( "GridUpdateButtons" ) = true
objVbsDbOrderDetails( "GridDeleteButtons" ) = true
objVbsDbOrderDetails( "ViewMode" ) = "Grid"
objVbsDbOrderDetails( "ViewNavigationButtons" ) = "first;prev;next;last;search;add"
objVbsDbOrderDetails( "InputSelectFields" ) = "ProductID|select ProductID,ProductName from Products "
"order by ProductName"
objVbsDbOrderDetails( "EditTableName" ) = "Order Details"
objVbsDbOrderDetails( "EditKeyFields" ) = "OrderID;ProductID"
objVbsDbOrderDetails( "EditAddFieldDefaults" ) = "OrderID|" & lngOrderId
objVbsDbOrderDetails( "EditReadOnlyFields" ) = "OrderID"
objVbsDbOrderDetails( "EditHideFields" ) = "Discount"
objVbsDbOrderDetails( "EditValidateRequiredFields" ) = "ProductID|ProductID is required.;UnitPrice|UnitPrice is " & _
"required.;Quantity|Quantity is required."
objVbsDbOrderDetails( "GlobalImageDir" ) = "VBSdb/images"
VbsDb objVbsDbOrderDetails
%>
This demonstrative program connects to
Nwind.mdb, the well known Microsoft Access sample database: the names of companies,
products, people,
characters, and/or data mentioned herein are fictious and are in no way
intended to represent any real individual, company, product, or event.
To download a copy of Nwind.mdb, please visit
Microsoft's site.
|