Technical Support

Getting Help from Microsoft Technical Support

If you can’t find the answers you need in the Data Access SDK documentation, you can resolve problems quickly through one of several options.

Note The services and prices listed here are available in the United States and Canada only and are subject to change without notice. Support outside the United States and Canada may vary. Contact the Microsoft subsidiary nearest you, using the Worldwide Subsidiary list in this documentation.

For questions specific to the Microsoft Developer Support Network (MSDN™), see the MSDN Support Policy in the /Visual Studio Documentation/Getting Started folder.

Support Online

Standard No-Charge Support

Pay-Per-Incident Support

Web Response

Additional Support

Support Outside the United States and Canada


If you have a simple question and need an answer fast

Quickly find your answers online

Use Support Online to search the Microsoft Knowledge Base and other technical resources for fast, accurate answers. You can also customize the site to control your search. To begin your search, go to http://support.microsoft.com/support.

For additional technical resources and information on developing with Microsoft products and technologies, visit MSDN online at http://www.microsoft.com/msdn/.


If your question is urgent and more complex

Telephone a Microsoft Technical Support engineer.

Microsoft Technical Support provides no-charge and fee-based support via telephone.

Standard No-Charge Support — for help during regular business hours

If you are using Microsoft Data Access Components in conjunction with a retail Microsoft product, see that product's individual help file for Standard No-Charge Support available, hours of operation, and telephone numbers to call.

This product, when used in conjunction with a non-Microsoft product, is not eligible for Standard No-Charge Support. Please see the Pay-Per-Incident section below.

If your Microsoft product was preinstalled or shipped with your personal computer, you are not eligible for Standard No-Charge Support from Microsoft and must contact your computer manufacturer for support. For phone numbers, please refer to the documentation that came with your computer.

Pay-Per-Incident Support — for help after hours or to supplement Standard Support

If you need help after hours, or are ineligible for Standard No-Charge Support, you can purchase Pay-Per-Incident Support for a fee of $95 U.S. per incident by calling (800) 936-5800. Support fees will be billed to your VISA, MasterCard, or American Express card. In the United States, you can also call (900) 555-2300 to have support fees applied to your telephone bill.


If your question isn't urgent

Send e-mail to a Microsoft Technical Support engineer.

With Web Response, you can conveniently submit questions via e-mail. This option is ideal for detailed questions or questions with attached files. You can submit questions 24 hours a day and will receive a response from an engineer within one business day. To submit your question, go to http://support.microsoft.com/support/ and select Web Response.

Standard No-Charge Web Response

Standard No-Charge Support incidents may be submitted for all eligible retail Microsoft products. If you are using Microsoft Data Access Components in conjunction with a retail Microsoft product, see that product's individual help file for the amount of Standard No-Charge Support available.

Pay-Per-Incident Web Response

You can submit your question for a fee of $95 U.S.


For additional support needs

If you don’t have access to the Internet

FastTips is an automated toll-free, fax-back service that provides popular Knowledge Base articles and quick answers to common technical questions. To gain access, dial (800) 936-4300.

If you need support services for a small, medium-sized, or large business

Priority Annual Support, Priority Plus, and Premier Support provide a selection of annual support packages that are geared for businesses. To determine which account best meets your business needs, go to http://support.microsoft.com/support/. Or call (800) 936-3500 for information on support options for small- to medium-sized businesses or (800) 936-3200 for large, enterprise businesses.

If you need on-site, multivendor, or proprietary product support

Microsoft Certified Solution Providers and Authorized Support Centers specialize in providing support packages for hardware, network, and software products from both Microsoft and other vendors. For more information or a referral to a Microsoft Certified Solution Provider, call (800) 765-7768 between 6:30 A.M. and 5:30 P.M. Pacific time, Monday through Friday, excluding holidays, or visit http://www.microsoft.com/mcsp. For more information on Authorized Support Centers, contact your Microsoft account representative, or visit http://www.microsoft.com/enterprise/asc.htm.

If you need text telephone (TTY/TDD) services

In the United States, call (425) 635-4948, or in Canada, call (905) 568-9641.

Microsoft support services are subject to Microsoft prices, terms, and conditions in place at the time the service is used and are subject to change without notice.


If you need support outside the United States and Canada

Microsoft Technical Support Worldwide

If you are outside the United States and have a question about a Microsoft product, first:

  • Check the information in this documentation.

  • Check the readme files that come with your product or in this documentation. These files provide general information that became available shortly before the product was released.

  • Go to Support Online from Microsoft Technical Support at http://support.microsoft.com/support/.

If you cannot find a solution, you can receive information on how to obtain technical support by contacting the Microsoft subsidiary office in your area.

Important Phone numbers for Microsoft Subsidiaries are subject to change. For the most recent listing, see the options and phone number section on the Support Online Web site at http://support.microsoft.com/support. If there is no Microsoft subsidiary office in your country/region, contact the establishment from which you obtained your Microsoft product.

  • Argentina

    Microsoft de Argentina S.A.
    Customer Service: (54) (1) 316-4600
    Fax: (54) (1) 316-4698
    Technical Support: (54) (1) 316-4664

  • Armenia

    See Russia

  • Australia

    Microsoft Pty. Ltd.
    Fax: (61) (02) 9805 1108
    Sales Information Centre: (61) (02) 9870-2100
    Internet: //www.microsoft.com.au/
    Technical Support: (61) (02) 9870-2131
    Fax: (61) (02) 9805 0519

  • Austria

    Microsoft Ges.m.b.H.
    Phone: (+43) 1 610 64 -0
    Fax: (+43) 1 610 64 -200
    Information: 0660-6520
    Prices, updates, etc.: 0660-6520
    Standard Support:
    Installation and Handling: 01 50222-2255
    General information about Support Network in Central Europe:
    Fax: 01805-251191

  • Azerbaijan

    See Russia

  • Belgium

    Microsoft NV
    Phone: +32-2-730 39 11
    Fax: +32-2-726 96 09
    Microsoft Information Center: +32-2-481 52 52
    Bulletin Board: +32-2-726 85 45 (14400/1200/2400/9600 bd, 8N1, ANSI)
    Technical Support:
    +32-2-513 32 74 (Dutch speaking)
    +32-2-502 34 32 (English speaking)
    +32-2-513 22 68 (French speaking)

  • Belorussia

    See Russia

  • Bolivia

    See Argentina

  • Brazil

    Microsoft Informatica Ltda.
    Phone: (55) (11) 5514 -7100
    Fax: (55) (11) 5514 - 7106/5514-7107
    Technical Support: (55) (11) 5506-8087
    Fax: (55) (11) 5506-7621
    Automatic Fax: (55) (11) 5506-8506
    Technical Support Bulletin Board Service: (55) (11) 5506-1234
    Customer Support: (55) (11) 822-5764

  • Canada

    Microsoft Canada Inc.
    Head Office Phone: 1 (905) 568-0434
    Customer Information Centre: 1 (800) 563-9048
    Technical Support:
    Desktop Systems including Microsoft Windows 95: (905) 568-4494
    Microsoft Office and Office Components: (905) 568-2294
    Other Standard Technical Support: (905) 568-3503
    Priority Support Information: (800) 668-7975
    Text Telephone (TTY/TDD) (905) 568-9641
    Technical Support Bulletin Board Service: (905) 507-3022

  • Caribbean

    Microsoft Caribbean, Inc.
    Phone: (809) 273-3600
    Fax: (809) 273-3636
    Technical Support: (214) 714-9100

  • Central America

    See Latin America

  • Chile

    Microsoft Chile S.A.
    Phone: 56-2-330-6000
    Fax: 56-2-330-6190
    Customer Service: 56-2-800-213121
    Personal Operating System and Desktop Applications:
    Phone: 56-2-330-6222
    Fax: 56-2-341-1439

  • China

    Microsoft (China) Co. Ltd
    4/F Kai Yuen Commercial Building
    No.28 Zhichunli, Hai Dian District
    Beijing 100086, PRC
    Phone: 011-86-10-6261-7711
    Fax: 011-86-10-6253-6630

  • Colombia

    Microsoft Colombia
    Phone: (571) 618 2245
    Fax: (571) 618 2269
    Technical Support:
    Línea de Respuesta Microsoft
    Phone: (571) 5230022
    Fax: (571) 5231220
    Voice Mail: (571) 5034216

  • Croatia

    Microsoft Hrvatska d.o.o.
    Phone: (+385) (1) 304 555
    Fax: (+385) (1) 335 051
    Technical Support: (Please, contact the subsidiary.)

  • Czech Republic

    Microsoft s.r.o.
    Phone (+42) (2) 611 97 111
    Fax: (+42) (2) 611 97 100
    Technical Support: (+420) (2) 2150 3222

  • Denmark

    Microsoft Denmark
    Phone: (45) 44 89 01 00
    Fax: (45) 44 68 55 10
    Technical Support:
    Phone: (45) 44 89 01 11
    Microsoft Sales Support: (45) 44 89 01 90
    Microsoft FastTips: (45) 44 89 01 44
    (Document 303030 in FastTips contains detailed instructions)
    Microsoft MSDL (BBS): (45) 44 66 90 46

  • Dominican Republic

    See Central America

  • Dubai

    Microsoft Middle East
    Phone: (971) 4 513 888
    Fax: (971) 4 527 444
    Technical Support:
    Personal Operating Systems and Desktop Applications ONLY:
    Phone: (971) (4) 524 488
    Fax: (971)- 4 - 524 495
    email: mts@emirates.net.ae
    Priority Support Information: (971) (4) 555 752
    Customer Service Center:
    (Version upgrade / TechNet and MSDN subscription)
    Phone: (971) (4) 655 082
    Fax: (971) (4) 655 097

  • Ecuador

    Corporation Microsoft del Ecuador S.A.
    Phone: (593) 2 460-447, (593) (2) 460-451
    Customer Service: (593) (2) 460-453, (593) (2) 460-458
    Technical Support: (593) (2) 463-094

  • Egypt

    Microsoft Egypt
    Phone: +202-418-6101
    Fax: +202-4174766
    Technical Support:
    Personal Operating Systems and Desktop Applications ONLY:
    Phone: (202) 261 3991 / 6
    Fax: (971) 403 2718

  • England

    See United Kingdom

  • Estonia

    See Germany
    Technical Support: (+372) 650 49 99

  • Finland

    Microsoft OY
    Phone: +358-(0) 9-525 501
    Fax: +358-(0) 9-878 8770
    Technical Support:
    Phone: +358-(0) 9-525 502 500
    Sales Support: +358-(0) 9-525 5026
    Microsoft MSDL: +358-(0) 9-878 77 99
    (Information in Swedish and English)
    Microsoft FastTips: +358-(0) 9-525 502 550
    (Information in Swedish and English)

  • France

    Microsoft France
    Phone: (33) 01 69-86-46-46
    Fax: (33) 01 64-46-06-60
    Telex: MSPARIS 604322
    Technical Support:
    Phone: (33) 01-69-86-10-20
    Fax: (33) (01) 69-28-00-28

  • French Polynesia

    See France

  • Georgia

    See Russia

  • Germany

    Microsoft GmbH
    Phone: 089/3176-0
    Fax: 089/3176-1000
    Telex: (17) 89/83 28 MS GMBH D
    Information: 089/3176 1199
    Prices, updates, etc.: 08105-25-1199
    Internet: www.microsoft.com/germany
    Standard Support:
    Installation and Handling: 01805/67 22 55
    General information about Microsoft support in Central Europe: Fax: 1805-25-1191

  • Greece

    Microsoft Hellas, S.A.
    Phone: (30)(1) 6806-775 through (30)(1) 6806-779
    Fax: (30)(1) 6806-780
    Technical Support:
    Phone: (30) (1) 9247-030
    Fax: (30) (1) 9215-363

  • Hong Kong

    Microsoft Hong Kong Limited
    Fax: (852) 2560-2217
    Product support Faxback Service: (852) 2535-9293
    Microsoft Club Hotline: (852) 28044277
    Technical Support: (852) 2804-4222

  • Hungary

    Microsoft Hungary
    Phone: +36 (1) 327-2800
    Fax: +36 (1) 327-2899
    Technical Support: +36 (1) 267-4636 (2MSINFO)

  • Iceland

    See Denmark

  • Ireland

    See United Kingdom

  • India

    Microsoft India
    Phone: (011) (91) (80) 5092678, (011) (91) (11) 646 0767, 646 0813
    Fax: (011) (91) (80) 509-2601, (011) (91) (11) 647- 4714

  • Indonesia (SP)

    Microsoft Indonesia - Jakarta
    Technical Support:
    Phone: 62 21 5721060
    Fax: 62 21 5732077

  • Israel

    Microsoft Israel Ltd.
    Phone: 972-3-613-0833
    Fax: 972-3-613-0834

  • Italy

    Microsoft SpA
    Phone: (39) (2) 7039-21
    Fax: (39) (2) 7039-2020
    Microsoft Rome Office: (39) (6) 5095-01 - Fax: (39) (6) 5095-0600
    Microsoft by Fax (Fax-on-demand service): (39) (2) 70-398-888
    Customer Service (New product info, product literature): (39) (2) 70-398-398
    Dealer Support (Customer Service for resellers only): (39) (2) 70-398-388
    Technical Support: (39) (2) 70-398-398
    Microsoft Consulting Service: (39) (2) 7039-21

  • Japan

    Microsoft Company Ltd.
    Technical Support (Standard Support): (81) (424) 41-8700
    (Technical Support options/ Support Contract)
    Phone: 0120-37-0196 (toll free domestic only)
    Channel Marketing Information Center:
    (Presales Product Support)
    Tokyo Phone: (81) (3) 5454-2300
    Osaka Phone: (81) (6) 245-6995
    Customer Service Phone:
    (Version upgrade/Registration)
    Phone: (81) (48) 226-5500
    Fax: (81) (48) 226-5511

  • Kazakhstan

    See Russia

  • Kirgizia

    See Russia

  • Korea

    Microsoft CH
    Phone: (82) (2) 531-4500
    Fax: (82) (2) 531-1724
    Customer Service: 080-022-7337 (toll free domestic only)
    Technical Support:
    Office Technical Support: (82) (2) 508-0040
    Windows Technical Support: (82) (2) 563-0054
    Developer Technical Support: (82) (2) 566-0071
    Microsoft FastTips: (82) (2) 3453-7555
    Support Sales: (82) (2) 531-4544

  • Latin America

    Microsoft
    Latin American Headquarters (U.S.A.)
    Phone: (305) 489-4800
    Fax: (305) 491-1616
    Customer Service: (425) 936-8661
    Technical Support: (214) 714-9100
    http://www.microsoft.com/latam/soporte

  • Liechtenstein

    See Switzerland (German speaking)

  • Luxembourg

    Microsoft NV
    Phone: +32-2-730 39 11
    Microsoft Information Center: +32-2-481 52 52
    Bulletin Board: +32-2-726 85 45
    (1200/2400/9600/14400 bd, 8N1, ANSI)
    Technical Support:
    +32-2-513 32 74 (Dutch speaking)
    +32-2-502 34 32 (English speaking)
    +32-2-513 22 68 (French speaking)

  • Malaysia (SP)

    Microsoft (Malaysia) Sdn Bhd:
    Phone: (60-3) 793-9595
    Fax: (60-3) 791-6080

  • México

    Microsoft México, S.A. de C.V.
    267-2110 Atencion a Distribuidores
    265-3380 Atencion a Clientes
    265-3399 Soporte Sistemas Operativos y Applicaciones de Escritorio
    267-2190 Soporte de Servidores y Herramientas de Desarrollo
    Fast Tips: (52)(5) 2612199
    Microsoft BBS 628-6200/02 MSMEXICO sin password

  • Morocco

    Microsoft Afrique Du Nord
    Phone: (212) 2 47 10 72
    Fax: (212) 2 47 10 86

  • Netherlands

    Microsoft BV
    Phone: 023-5689189
    Customer Service: 023-5677700
    Bulletin Board: 023-5634221
    (1200/2400/9600/14400bd, 8N1, ANSI)
    Technical Support:
    023-5677877 (Dutch speaking)
    023-5677853 (English speaking)

  • New Zealand

    Microsoft New Zealand Ltd
    Phone: 64 (9) 357-5800
    Fax: 64 (9) 358-3726
    Technical Support:
    Phone: 64 (9) 357-5575
    Fax: 64 (9) 307-0516 and 357-5577

  • Northern Ireland

    See United Kingdom

  • Norway

    Microsoft Norway AS
    Phone: +(47) 22 02 25 00
    Fax: +(47) 22 95 06 64
    Technical Support: +(47) 22 02 25 50
    Microsoft Sales Support: +(47) 22 02 25 80
    Microsoft MSDL: +(47) 22 18 22 09
    Microsoft FastTips: +(47) 22 02 25 70
    (Document 404040 in FastTips contains detailed instructions)

  • Papua New Guinea

    See Australia

  • Paraguay

    See Argentina

  • Peru

    See Latin America

  • Philippines (SP)

    Microsoft Philippines
    Phone: 632 811 0062
    Technical Support:
    Phone: 632 892 2295/2495
    Fax: 632 813 2493

  • Poland

    Microsoft Sp. z o.o.
    Phone: +(48-22) 661-54-00
    Fax: +(48-22) 661-54-34
    Information Service: +(48-22) 865-99-33
    Technical Support: +(48-22) 865-99-66

  • Portugal

    Microsoft Portugal MSFT, Lda.
    Phone: (351) 1 4409200
    Fax: (351) 1 4412101
    Technical Support:
    Standard Support: (351) 1 4409280/1/2/3
    Fax: (351) 1 4411655
    Republic of Ireland
    See United Kingdom

  • Romania

    Microsoft s.r.l.
    Phone: (+40) (1) 222 90 16
    Fax: (+40) (1) 222 90 12
    Technical Support: (+40) (1) 312 09 48

  • Russia

    Microsoft A/O
    Microsoft Information Center: (095)-913-99-88

  • Scotland

    See United Kingdom

  • Saudi Arabia

    Microsoft Saudi Arabia
    Phone: +966-1-488-1165
    Fax: +966-1-488-1576
    Technical Support:
    (Personal Operating System and Desktop Applications only):
    Phone: 800 124 0500
    (toll free within Saudi Arabia)
    Fax: 966-1-4740576

  • Singapore

    Microsoft Singapore Pte Ltd
    Phone: (65) 337-6088
    Fax: (65) 337-6788
    Customer Services:
    Phone: (65) 433-5488
    Fax: (65) 339-9958
    Product Support Services:
    Phone: (65) 337-9946
    Fax: (65) 337-6700

  • Slovenia/Slovenija

    Microsoft d.o.o.
    Phone: (+386) (61) 1800 8-00
    Fax: (+386) (61) 1800 822
    Technical Support: (+386) (61) 185 3449

  • Slovak Republic

    Microsoft Slovakia s.r.o.
    Phone (+421) (7) 37 63 02
    Fax: (+421) (7) 37 66 71
    Technical Support: (+421) (7) 531 20 83

  • South Africa

    Microsoft South Africa
    Phone: (27) 11 445 0000
    Fax: (27) 11 445 0046
    Technical Support:
    (Toll Free): 0 802 11 11 04
    (Toll): (27) 11 445 0000
    Fax: (+27) 11 445-0343

  • South East Africa and Indian Ocean Islands

    See South Africa

  • Spain

    Microsoft Iberica SRL
    Phone: (34) 1-807-9999
    Fax: (34) 1-803-8310
    Technical Support: (34) 1 -3754004
    Customer Service: (34) 1-3754004
    Fax Back telephone: (34) 1-3754004

  • Sweden

    Microsoft AB
    Phone: +46-(0)8-752 56 00
    Fax: +46-(0)8-750 51 58
    Technical Support: +46-(0)8- 752 09 29
    Sales Support: +46-(0)8- 752 56 30
    Microsoft MSDL: +46-(0)8-750 47 42
    Microsoft FastTips: +46-(0)8-752 29 00
    (Document 202020 in FastTips contains detailed instructions)

  • Switzerland

    Microsoft AG
    Phone: 01-839 61 11
    Fax: 01-831 08 69
    Prices, updates, etc.: 01/839 61 11
    Documentation:
    Phone: 155 59 00
    Fax: 064-224294, Microsoft Info-Service, Postfach, 8099 Zürich
    Standard Technical Support: Installation and Handling:
    0848 80 - 2255
    Technical support (French speaking): 022-738 96 88
    General information about Microsoft Support in Central Europe:
    FAX: 0049/2622/167006

  • Tadzhikistan

    See Russia

  • Taiwan Region

    Microsoft Taiwan Corp.
    Phone: (886) (2) 504-3122
    Fax: (886) (2) 504-3121
    Technical Support: (886) (2) 508-9501

  • Thailand

    Microsoft (Thailand) Limited
    Phone: (662) 266-3300
    Fax: (662) 266-3310
    Product Support:
    Phone: (662) 613-7208 through 11
    Fax: (662) 613-7198

  • Turkey

    Microsoft Turkey
    Phone: 90 (212) 258 59 98
    Fax: 90 (212) 258 59 54
    Support Hotline:
    Phone: 90 (212) 258 96 66
    Fax: 90 (212) 258 95 99
    Bulletin Board Service: 90 (212) 227 93 90

  • Turkmenistan

    See Russia
    United Kingdom
    Microsoft Limited
    Fax: (0870) 60 20 100
    Phone: (0870) 60 10 100
    Microsoft KeyData:
    (Bulletin Board Service)
    (0870) 50 30 200 (up to 28.8Kbaud, n, 8, 1)
    Microsoft KeyFax:
    (Faxback Information Service)
    (0870) 50 30 100
    Technical Support:
    Desktop Applications, Home Products, Desktop Systems and hardware:
    0870 50 10 100
    Developer Products: 0870 50 10 200
    Business Systems: 0870 50 10 300
    Customers phoning from Ireland should dial 706 5353 for technical support.
    Minicom Line 0870 50 30 400
    Pre-Sales Information: Microsoft Connection (0345) 00 2000

  • Uruguay

    Technical Support: (598) (2) 77-4934

  • Uzbekistan

    See Russia

  • Venezuela

    Corporation MS 90 de Venezuela S.A.
    Other information: (582) 265-9922
    Fax: (582) 265-0863
    Technical Support: (582) 993-6755

  • Wales

    See United Kingdom


DA SDK Copyright and Trademarks

Microsoft Data Access SDK Copyright and Legal Information

Information in this document is subject to change without notice. The names of companies, products, people, characters, and/or data mentioned herein are fictitious and are in no way intended to represent any real individual, company, product, or event, unless otherwise noted. Complying with all applicable copyright laws is the responsibility of the user. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Microsoft Corporation. If, however, your only means of access is electronic, permission to print one copy is hereby granted.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

Microsoft, MS, ActiveX, BackOffice, Developer Studio, FoxPro, JScript, Microsoft Press, MSDN, MS-DOS, PivotTable, Visual Basic, Visual C++, Visual InterDev, Visual J++, Visual Studio, Win32, Windows, and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries.

Apple and Macintosh are registered trademarks of Apple Computer, Inc.

Intel is a registered trademark of Intel Corporation.

Other product and company names mentioned herein may be the trademarks of their respective owners.


Microsoft Data Access SDK Overview

The Microsoft® Data Access SDK is the primary source of information and instruction on using data access technologies. Its tools, samples, and documentation are designed to help developers create solutions for their data access needs. For the latest news and updates about the data access technologies, go to the Microsoft Data Access Web site http://www.microsoft.com/data.

For information on support for Microsoft data access components, see the Getting Help from Microsoft Technical Support page.

© 1998 Microsoft Corporation. All rights reserved.

Universal Data Access

Universal Data Access is the Microsoft strategy for providing access to information across the enterprise. Universal Data Access provides high-performance access to a variety of relational and nonrelational information sources, and an easy-to-use programming interface that is tool and language independent. These technologies enable you to integrate diverse data sources, create easy-to-maintain solutions, and use your choice of best-of-breed tools, applications, and platform services.

Universal Data Access does not require expensive and time-consuming movement of data into a single data store, nor does it require commitment to a single vendor’s products. Universal Data Access is based on open industry specifications with broad industry support, and works with all major established database platforms.

The Microsoft Universal Data Access Web site (www.microsoft.com/data/) provides a central location for you to learn about Universal Data Access and the technologies that make it possible. Here you will find information and the latest news about these technologies.

Microsoft Data Access Components Overview

The Microsoft® Data Access Components (MDAC) are the key technologies that enable Universal Data Access. Data-driven client/server applications deployed over the Web or a LAN can use these components to easily integrate information from a variety of sources, both relational (SQL) and nonrelational. These components include Microsoft® ActiveX® Data Objects (ADO), OLE DB, and Open Database Connectivity (ODBC).

ActiveX Data Objects (ADO)

Microsoft ActiveX Data Objects (ADO) is the strategic application programming interface (API) to data and information. ADO provides consistent, high-performance access to data and supports a variety of development needs, including the creation of front-end database clients and middle-tier business objects that use applications, tools, languages, or Internet browsers. ADO is designed to be the one data interface needed for single and multitier client/server and Web-based data-driven solution development. The primary benefits of ADO are ease of use, high speed, low memory overhead, and a small disk footprint.

ADO provides an easy-to-use interface to OLE DB, which provides the underlying access to data. ADO is implemented minimal network traffic in key scenarios, and a minimal number of layers between the front end and data source—all to provide a lightweight, high-performance interface. ADO is easy to use because it uses a familiar metaphor—the COM automation interface, available from all leading Rapid Application Development (RAD) tools, database tools, and languages on the market today.

OLE DB

OLE DB is the Microsoft strategic system-level programming interface to data across the organization. OLE DB is an open specification designed to build on the success of ODBC by providing an open standard for accessing all kinds of data. Whereas ODBC was created to access relational databases, OLE DB is designed for relational and nonrelational information sources, including mainframe ISAM/VSAM and hierarchical databases; e-mail and file system stores; text, graphical, and geographical data; custom business objects; and more.

OLE DB defines a collection of COM interfaces that encapsulate various database management system services. These interfaces enable the creation of software components that implement such services. OLE DB components consist of data providers, which contain and expose data; data consumers, which use data; and service components, which process and transport data (such as query processors and cursor engines). OLE DB interfaces are designed to help components integrate smoothly so that OLE DB component vendors can bring high-quality OLE DB components to market quickly. In addition, OLE DB includes a bridge to ODBC to enable continued support for the broad range of ODBC relational database drivers available today.

Open Database Connectivity (ODBC)

The Microsoft Open Database Connectivity (ODBC) interface is an industry standard and a component of Microsoft® Windows® Open Services Architecture (WOSA). The ODBC interface makes it possible for applications to access data from a variety of database management systems (DBMSs). ODBC permits maximum interoperability—an application can access data in diverse DBMSs through a single interface. Furthermore, that application will be independent of any DBMS from which it accesses data. Users of the application can add software components called drivers, which create an interface between an application and a specific DBMS.

Next:

Getting Around the Data Access SDK

Building Solutions Using Data Access Technologies

Installing the Data Access SDK

Redistributing Data Access Components


Getting Around the Data Access SDK

This chart is designed to guide you through the Data Access SDK. Look on the chart to find DA SDK information on what you want to learn, the problem you want to solve, or an activity you want to do. For a better understanding of DA SDK technologies, we recommend that everyone read the Universal Data Access technical article, “Microsoft Strategy for Universal Data Access.”

Tasks | Go To | Lang
  • Learn about data access technologies
Novice

“Microsoft Strategy for Universal Data Access” technical article

"Data Access Technologies" technical article

"Making Universal Data Access a Reality" technical article

"Universal Data Access Q & A" technical article

Microsoft Data Access ComponentsOverview

ActiveX Data Objects (ADO) Overview

OLE DB Overview

ODBC Overview
Experienced with RDO/DAO or PowerBuilder/Delphi Tools

“Microsoft Strategy for Universal Data Access” technical article

"Data Access Technologies" technical article

"Making Universal Data Access a Reality" technical article

“Exploring ActiveX Data Objects from an RDO Point of View” technical article

“Manage Data from Myriad Sources with the Universal Data Access Interfaces” technical article
  • Use Visual Basic to create an application that uses data accessed from different data sources
 ActiveX Data Objects (ADO)

ADO Overview

ADO Tutorial

 VB
  • Use a browser to create an application that uses data accessed from different data sources
ActiveX Data Objects (ADO)

ADO Overview

ADO Tutorial

ADO Samples

Online Catalog Application Sample

 ASP
  • Use multidimensional data
 ADO MD VB, VC, VJ
  • Create a data-bound control
 ActiveX Control Writer
  • Expose data and services through OLE DB
OLE DB novice

"Data Access for the Masses" technical article

VC++ ActiveX Template

OLE DB Overview

OLE DB Samples

OLE DB Reference

 VC
OLE DB Simple Provider Toolkit | VB, VC, VJ
OLE DB expert

“OLE DB Leveling” technical article

"Conformance Testing in OLE DB" technical paper

OLE DB Providers

OLE DB Reference

Test Module Template

 VC
Use multidimensional data

OLE DB for Online Analytical Processing Overview
  • Expose SQL data through ODBC
 ODBC Overview

OLE DB for the ODBC Programmer


Building Solutions Using Data Access Technologies

Building Solutions Using Data Access Technologies Overview

Four real-world applications make up the set of solution samples. Each of these applications provides a solution for a common, real-world scenario. In addition, each application demonstrates specific MDAC features.

The four applications are:

  • Online Catalog and Order Placement
    Enables consumers to browse catalog products and place orders over the Internet.

  • MIS Inventory Management and Executive Reports (next release)
    Provides MIS employees a way to manage a list of product items and status codes within the master database and generates statistical reports.

  • Warehouse Order Fulfillment (next release)
    Provides warehouse employees a way to record the shipping of orders and prints reports.

  • Contact Management and Sales Forecasting (next release)
    Enables traveling salespeople to manage contacts with clients and record sales forecasts offline.

The applications all use a common database and related tables, so the results carried out in one application can appear in another application.


Installing the Data Access SDK

The Microsoft Data Access SDK is the primary source of information and instruction on using data access technologies. Its tools, samples, and documentation are designed to help developers create solutions for data access needs.

The SDK also contains tools and information for developing OLE DB providers, ODBC drivers, ADO, RDS, and, headers and libs for Visual C++ developers. For the latest news and updates on the data access technologies go to our website at www.microsoft.com/data.

If you're installing the SDK from Visual Studio, the documention for the SDK is in the MSDN CD, installed by Visual Studio. There are help files and other documentation in \msdasdk\doc directory.

If you are installing the standalone version of the SDK, the documentation is installed directly with the SDK. You can access it from the Start menu in the Data Access SDK program group.

Directory Structure

Setup installs the files in the following directories on your disk. These are subdirectories of the default installation directory \Msdasdk.

Directory | Description
bin | Binary files for all SDK components
conformance | Tests to run on your provider/driver to prove conformance to OLE DB Standards
doc | Documentation and Help file directory
HookOLE | HookOle files for use by OLE DB Spy
include | Header files for SDK components
lib | Library files for SDK components
misc | Miscellaneous file
redist | Redistributable files
samples | Subdirectories containing source for all samples
testmod | QuikTest module files which provide a useful overview of provider functionality
unsupported | Unsupported files

Subdirectory | Description
ado | ActiveX Data Objects specific files
oledb | OLE DB specific files
odbc | Open Database Connectivity specific files
osp | OLE DB Simple Provider Toolkit specific files
mdac | Microsoft Data Access Components specific files
rds | Remote Data Service specific files
acw | ActiveX Control Writer Toolkit files

SDK Samples

The following samples are included:

MDAC Sample

Online Catalog Application Sample

Demonstrates a three-tier Web application. The application uses any standard HTML browser. The server side uses Active Server Pages to format the output and for order placement and inquiry.

ADO Samples

GetRows Sample

A C/C++ sample that demonstrates the use of the Recordset object's GetRows method to retrieve all the rows of a rowset into a 2-dimensional array.

Employee Sample

Displays data in a form that allows you to scroll, insert,update and delete data.

ADORead Sample

A C/C++ sample that generates timings for fetching data using different cursor types and cache sizes.

ADOasp Sample

An Active Server Pages sample that lets clients browse through components and obtain data.

ADOISAPI Sample

A C/C++ ISAPI extension sample that establishes a cached connection to a database, fetched data, formats the data as an html table.

ADOjava Sample

A Visual J++ sample that demonstrates Java/COM integration.

ADOvbs

A VBSrcipt sample that builds a 2-tier application for an intranet.

OLE DB Samples

Query Demo Sample

Demonstrates how to build a consumer capable of issuing queries.

Rowset Viewer Sample

Provides a simple way to view and manipulate rowsets.

Table Copy Sample

Demonstrates a simple consumer that reads data from one OLE DB rowset and saves it as a new table.

Sample Consumer

Demonstrates how to build a simple consumer.

OLAP client applications Sample

Demonstrates working with any multidimensional data provider exposing OLE DB for OLAP interfaces and includes a provider with sample Olap multidimensional database (BobsVideo.cub) to query.

ODBC Samples

Admin Demo Sample

Demonstrates how to connect to a data source, execute SQL statements, run scripts, and perform other special tasks. It can list information (such as data types, functions, and general ODBC information) about the data source being used.

Cursor Demo Sample

Demonstrates the block cursor, scrolling, positioned update, and delete capabilities of the ODBC Cursor Library.

Query Demo Sample

Demonstrates multiple simultaneous connections.

Convert DSN Demo Sample

Demonstrates how to convert User and System DSNs to File DSNs.

Predefined ODBC Data Sources

The DA SDK contains the following 32-bit ODBC data sources:

OLE_DB_NWind_Jet

This data source points to the NorthWind Access database shipped with the DA SDK. This is \msdasdk\bin\oledb\nwind.mdb.

OLE_DB_NWind_SQL

This data source points to the Microsoft SQL Server "pubs" database. The server is set to "." and the database name is set to "pubs". You may need to modify this data source to use it on your system.


Redistributing Data Access Components

This section contains the list of the Data Access Components redistributable files, as well as instructions on how to run the redistributable stanalone EXE's that installs all the necessary files for running any Data Access aware application on your client machine.

Running the Redistribution Setup from the Command-Line in Silent Mode

In a DOS window, enter:

mdac_typ.exe /q:a /c:"setup.exe /qt"

The /q:a switch removes all user interfaces from the standalone wrapper.

The /qt switch removes all user interfaces from the MS installer.

Extracting the DA SDK and Setup Files

In a DOS window, enter:

mdac_typ.exe /C /T:DirectoryPath

The /C switch specifies to extract the files with running setup.

The /T:DirectoryPath specifies the directory where you want the extracted files placed.

Redistributable Components Filelist

The following files are redistributable:

RDS 2.0

File Name | Description
msadds.dll | Shape Provider (Hierarchial Rowsets)
msaddsr.dll | Shape Provider Resource Library
msdaprst.dll | Persistence Provider
msdatsrc.tlb | Data Binding
msadce.dll | Cursor Engine
msadcer.dll | Cursor Engine Resource Library
msadcf.dll | Data Factory
msadcfr.dll | Data Factory Resource Library
msadco.dll | Client-side ADC objects, including ADC control and SOAP proxy
msadcor.dll | Client-side ADC objects Resource Library
msadcs.dll | SOAP stub, ISAPI dll
mdac20.cab | Client cab
adcjavas.inc | Include file for JavaScript
adcvbs.inc | Include file for VBScript
msdfmap.dll | Data factory handler core
msdfmap.ini | Initializes the Data factory handler core
handler.reg | Register and include file

RDS 1.1

File Name | Descriptiom
mdac11.cab | RDS 1.1 cab

ADO 2.0

File Name | Description
msader15.dll | ADO Error String Library
msado15.dll | ADO Library
msador15.dll | ADO Recordset Object
msadrh15.dll | Rowset helper dll
adojavas.inc | Include file for JavaScript
adovbs.inc | Include file for VBScript
ADOreadme.txt | Release Notes
adoapt15.reg | Apartment-Threading
adofre15.reg | Free-Threading
makapt15.bat | Batch file for Apartment-Threading
makfre15.bat | Batch file for Free-Threading

OLE DB Core

File Name | Description
msdadc.dll | OLE DB Data Conversion Library
msdaenum.dll | OLE DB Root Enumerator object
msdaer.dll | OLE DB Error object
msdaerr.dll | OLE DB Error Object Resource Library
msdaps.dll | OLE DB Interface Remote
msdatt.dll | OLE DB Temporary Table Service Provider
msdatl2.dll | Tools library

OLE DB ODBC Provider 2.0

File name | Description
msdasql.dll | ODBC Provider
msdasqlr.dll | ODBC Provider Resource Library
"MSDASQLreadme.txt" | ODBC Provider Release Notes

ODBC 3.51

File Name | Description
ds16gt.dll | 16-bit driver setup generic thunking
ds32gt.dll | 32-bit driver setup generic thunking
mtxdm.dll | Connection Pooling Manager
odbc16gt.dll | 16-bit ODBC generic thunking
odbc32.dll | 32-bit Driver Manager
odbc32gt.dll | 32-bit ODBC generic thunking
odbcad32.exe | 32-bit Administrator program
odbccp32.cpl | 32-bit Administrator Control Panel Applet
odbccp32.dll | 32-bit installer
odbccr32.dll | ANSI Cursor Library
odbccu32.dll | Unicode Cursor Library
odbcint.dll | 16-bit installer
odbctrac.dll | ODBC Trace
odbcinst.hlp | Installer Help file
odbcinst.cnt | Installer Help Table of Contents file

SQL Server ODBC Driver 3.5

File Name | Description
12520437.cpx | Translation Code Page
12520850.cpx | Translation Code Page
mscpxl32.dll | Translation
sqlsrv32.dll | SQL Server ODBC Driver
odbcbcp.dll | SQL Server BCP Library
windbver.exe | SQL Serverr Client Configuration Utility
sqlsodbc.hlp | Help File
SQLSRdMe.txt | Release Notes

SQL Server OLE DB Provider 1.0

File Name | Description
SQLOLEDB.DLL | SQL Server OLE DB Provider
dbmsshrn.dll | Shared Memory Net-Library
dbnmpntw.dll | Named Pipes Net-Library
dbmssocn.dll | Sockets Net-Library
instcat.sql | Updated System Stored Procedure Catalog
SQLSOLDB.hlp | Help File

Oracle ODBC Driver 2.0

File Name | Description
msorcl32.dll | Microsoft ODBC Driver for Oracle
mtxoci.dll | Microsoft database support DLL for Oracle
msorcl32.hlp | Help File
msorcl32.cnt | Table of Contents for Help File
MsOracle32Readme.txt | Release Notes

Oracle OLE DB Provider 1.0

File Name | Description
msdaora.dll | Microsoft OLE DB Provider for Oracle
mtxoci.dll | Microsoft database support DLL for Oracle
MSOrclOLEDBreadme.txt | Release Notes

Jet 3.51

File Name | Description
msjet35.dll | Microsoft Jet Database Engine
msjint35.dll | International Resource File
msjter35.dll | Error Services File
msrd2x35.dll | IISAM for Jet 2.0 Databases
msrepl35.dll | Jet Replication Library
expsrv.dll | Express Service
vbajet32.dll | Express Service
msexch35.dll | Exchange Installable ISAM
msexcl35.dll | Excel Installable ISAM
mspdox35.dll | Paradox Installable ISAM
msltus35.dll | Lotus Installable ISAM
mstext35.dll | Text Installable ISAM
msxbse35.dll | Xbase Installable ISAM

Jet OLE DB 3.52

File Name | Description
MSJTOR35.DLL | Jet OLEDB Provider
MSJT4JLT.DLL | Jet forOLEDB
JoltReadme.txt | Jet OLEDB Provider Release Notes

ODBC Driver for Desktop Databases

File Name | Description
odbcji32.dll | ODBC Driver Resource Library
odbcjt32.dll | ODBC Driver for Desktop Databases
odbctl32.dll | Utility Routines
oddbse32.dll | dBase Setup
odexl32.dll | Excel Setup
odfox32.dll | FoxPro Setup
odpdx32.dll | Paradox Setup
odtext32.dll | Text Setup
odbcjet.hlp | Help File
odbcjet.cnt | Release Notes

Visual FoxPro ODBC Driver

File Name | Description
vfpodbc.dll | FoxPro ODBC Driver
vfpodbc.txt | Release Notes
drvvfp.hlp | Help file
drvvfp.cnt | Table of Contents for Help File

OSP Toolkit

File Name | Description
msdaosp.dll | OLE DB mapping layer file

Service Components

File Name | Description
MSDASC.DLL | Service Components
msdasc.hlp | Help File for Data Links UI
msdasc.cnt | Table of Contents for Help File
msdasc .txt | Release Notes


validatePassword.asp Module Code

The validatePassword.asp module retrieves and displays the information of one product. The main steps are:

  • The Connection Object: Making and opening a connection

  • The Command Object: Specifying a query that is a stored procedure

  • The Parameter Object: Specifying the input and output parameters of a command

  • The Parameter Object: Assigning values to the input parameters of a command

  • The Command Object: Creating an active connection and executing a command

  • The Parameter Object: Assigning values from the output parameters of a command to session variables
  1. The Connection Object: Making and opening a connection

    This application first uses the following steps to define a connection to a database by setting up a Connection object to reference the data source:

    1. Set up the Connection object.

    2. Return the number of seconds to wait when creating a connection before stopping the attempt and returning an error specified in the global.asa module.

    3. Return the number of seconds to wait when executing a command before stopping the attempt and returning an error specified in the global.asa module.

    4. Specifies the data source and user name to apply when opening the connection.

    5. Open the connection:

    The corresponding code follows:

    Set connPubs = Server.CreateObject("ADODB.Connection")
connPubs.ConnectionTimeout = Session("accts_ConnectionTimeout")
connPubs.CommandTimeout = Session("accts_CommandTimeout")
connPubs.ConnectionString = "DSN=Sample;UID=sa;"
connPubs.open
  2. The Command Object: Specifying a query that is a stored procedure

    After creating and opening a connection, the application sets up a Command object by using the following steps:

    1. Set up the Command object.

    2. Specify the text of the command to execute.

    3. Specify that the command text is a stored procedure.

    The corresponding code follows:

    Set cmdPubs = Server.CreateObject("ADODB.Command")cmdPubs.CommandText = "sp_validate_password"
cmdPubs.CommandType = adCmdStoredProc
  3. The Parameter Object: Specifying the input and output parameters of a command

    After creating a Command object, the application sets up a Parameter object by using the following steps:

    1. Set up the Parameter object collection.

    2. Add the following input parameters to the collection:

      @pivcEmailAddress of type Character with a size of 64

      @pivcPassword of type Character with a size of 32

    3. Add the following output parameters to the collection:

      @poiCustomerId of type Integer with a size of 4

      @poiReturnCode of type Integer with a size of 4

    The corresponding code follows:

    set p = cmdPubs.Parameters

p.Append cmdPubs.CreateParameter("@pivcEmailAddress", adVarChar,     adParamInput, 64)
p.Append cmdPubs.CreateParameter("@pivcPassword", adVarChar,     adParamInput, 32)

p.Append cmdPubs.CreateParameter("@poiCustomerID", adInteger,     adParamOutput, 4)
p.Append cmdPubs.CreateParameter("@poiReturnCode", adInteger,     adParamOutput, 4)
  4. The Parameter Object: Assigning values to the input parameters of a command

    The following code specifies the values to assign to the input parameters:

    cmdPubs("@pivcEmailAddress") = Session("cEmailAddress")
cmdPubs("@pivcPassword") = Session("cPassword")
  5. The Command Object: Creating an active connection and executing a command

    The following code specifies the connection to use and then executes a command:

    Set cmdPubs.ActiveConnection = connPubs
cmdPubs.Execute
  6. The Parameter Object: Assigning values from the output parameters of a command to session variables

    The following code assigns the values of the output parameters to session variables:

    Session("CustomerID") = cmdPubs("@poiCustomerID")Session("rcPassword") = cmdPubs("@poiReturnCode")


validateEmailNew.asp Module Code

The validateEmailNew.asp module checks the customer's e-mail name and password, stores e-mail information in the input parameter, and stores the password in the output parameter. The main steps are:

  • The Connection Object: Making and opening a connection

  • The Command Object: Specifying a query that is a stored procedure

  • The Parameter Object: Specifying the input and output parameters of a command

  • The Parameter Object: Assigning a value to the input parameter of a command

  • The Command Object: Creating an active connection and executing a command

  • The Parameter Object: Assigning a value from the output parameter of a command to session variables
  1. The Connection Object: Making and opening a connection

    This application first uses the following steps to define a connection to a database by setting up a Connection object to reference the data source:

    1. Set up the Connection object.

    2. Return the number of seconds to wait when creating a connection before stopping the attempt and returning an error specified in the global.asa module.

    3. Return the number of seconds to wait when executing a command before stopping the attempt and returning an error specified in the global.asa module.

    4. Specify the data source and user name to apply when opening the connection.

    5. Open the connection.

    The corresponding code follows:

    Set connPubs = Server.CreateObject("ADODB.Connection")
connPubs.ConnectionTimeout = Session("accts_ConnectionTimeout")
connPubs.CommandTimeout = Session("accts_CommandTimeout")
connPubs.ConnectionString = "DSN=Sample;UID=sa;"
connPubs.open
  2. The Command Object: Specifying a query that is a stored procedure

    After creating and opening a connection, the application sets up a Command object by using the following steps:

    1. Set up the Command object.

    2. Specify the text of the command to execute.

    3. Specify that the command text is a stored procedure.

    The corresponding code follows:

    Set cmdPubs = Server.CreateObject("ADODB.Command")cmdPubs.CommandText = "sp_is_email_address_new"
cmdPubs.CommandType = adCmdStoredProc
  3. The Parameter Object: Specifying the input and output parameters of a command

    After creating a Command object, the application sets up a Parameter object by using the following steps:

    1. Set up the Parameter object collection.

    2. Add the following input parameter to the collection:

      @pivcEmailAddress of type Character with a size of 64

    3. Add the following output parameter to the collection:

      @poiReturnCode of type Integer with a size of 4

    The corresponding code follows:

    set p = cmdPubs.Parameters
p.Append cmdPubs.CreateParameter("@pivcEmailAddress", adVarChar,
adParamInput, 64)p.Append cmdPubs.CreateParameter("@poiReturnCode",    adInteger,
adParamOutput, 4)
  4. The Parameter Object: Assigning a value to the input parameter of a command

    The following code specifies the value to assign to the input parameter:

    cmdPubs("@pivcEmailAddress") = Session("cEmailAddress")
  5. The Command Object: Creating an active connection and executing a command

    The following code specifies the connection to use and then executes a command:

    Set cmdPubs.ActiveConnection = connPubs
cmdPubs.Execute
  6. The Parameter Object: Assigning a value from the output parameter of a command to a session variable

    The following code assigns the value of the output parameter to a session variable:

    Session("rcPassword") = cmdPubs("@poiReturnCode")


Online Catalog Sample Modules Overview

Each module uses different pieces of the MDAC technology. The following table includes a brief description of all the modules used.

Module Name | Description
OrderEntry.css | Specifies styles included in each display module. Varies depending on browser.
adovbs.inc | Contains the ADO VB script constants.
adojavas.inc | Contains the ADO Java script constants.
CompanyTitle.inc | Displays the Company Title at the head of each page.
ParentCategoryTree.inc | Manages the Parent Categories stack that appears near the top of some of the forms.
global.asa | Sets up global variables for the application.
default.asp | Designates the home page that links to the Online Catalog, Shopping Cart, Order Status, Your Profile pages.
getCategories.asp | Gets a list of Product Categories by storing a Recordset into session variable arrays.
Category.asp | Displays list of categories that customer can click to drill down. Uses session variable arrays to populate the form.
catalog.asp | Retrieves the list of products by using a Command Object and displays it.
Product.asp | Retrieves the information about a product and displays it.
Customize.asp | Sets customizable properties in the Parent Categories Stack. Uses the SHAPE Provider to get a hierarchical recordset.
addToShoppingCart.asp | Adds a product to the shopping cart by adding a row to arrays held in session variables.
removeFromShoppingCart.asp | Removes a product from the shopping cart by deleting a row from arrays held in session variables.
ShoppingCart.asp | Displays the contents of the Shopping cart by displaying the arrays held in session variables.
initLogin.asp | Initializes the customer login process.
Login.asp | Collects the customer login information.
validatePassword.asp | Validates the user login information. If a customer profile exists, stores return code passed as output parameters in session variables. If a customer profile does not exists, creates new profile, stores output parameters in session variables and stores session variables in input parameters.
LoginNewUser.asp | Gets a password for a new customer by using session variables.
validateEmailNew.asp | Checks customer's e-mail name and password, stores e-mail information in input parameter, and stores password in output parameter.
getAddress.asp | Gets customer's profile, outputs one row of a resultset into session variables.
Address.asp | Displays customer profile information by getting data out of session variables.
showAddress.asp | Displays user profile by getting data out of session variables.
getSearchItems.asp | Runs a search by dynamically building a SQL string and executing it.
Checkout.asp | Displays shopping cart contents by getting data out of arrays in session variables.
setShoppingCart.asp | Adds Shopping cart to Order tables by using one connection for several Command objects.
setOrders.asp | Adds shopping cart contents to an order table by executing several commands in stored procedures over one connection that uses input and output parameters.
initStatus.asp | Initializes the Status Query Process by setting session variables to a hold state.
Status.asp | Displays the status of a customer's order by using two connections simultaneously.
StatusSummary.asp | Displays a clickable summary list of Orders.
AccountsRCTranslate.asp | Formats error code by using a two-dimensional array.
AckChangeAddressBody.asp | Maintains customer profile.


setOrders.asp Module Code

The setOrders.asp module adds shopping cart contents to an order table by executing several commands in stored procedures over one connection that uses input and output parameters. The main steps are:

  • The Connection Object: Making and opening a connection

  • The Command Object: Specifying a query that is a stored procedure

  • The Parameter Object: Specifying the input and output parameters of a command

  • The Parameter Object: Assigning values to the input parameters of a command

  • The Command Object: Creating an active connection and executing a command

  • The Parameter Object: Assigning a value from the output parameter of a command to a session variable

  • Clearing the Command Object

  • Clearing the Parameter Object

  • The Command Object: Specifying a new query that is a stored procedure

  • The Parameter Object: Specifying the input parameters of a command

  • Assigning the Values of Session Variables to Temporary Variables

  • The Parameter Object: Assigning values to the input parameters of a command

  • Constructing an SQL Query from Session Variables

  • Executing a Command with the Connection Object

  • The Command Object: Creating an active connection and executing a command

  1. The Connection Object: Making and opening a connection

    This application first uses the following steps to define a connection to a database by setting up a Connection object to reference the data source:

    1. Set up the Connection object.

    2. Return the number of seconds to wait when creating a connection before stopping the attempt and returning an error specified in the global.asa module.

    3. Return the number of seconds to wait when executing a command before stopping the attempt and returning an error specified in the global.asa module.

    4. Specify the data source and user name to apply when opening the connection.

    5. Open the connection.

    The corresponding code follows:

    Set connPubs = Server.CreateObject("ADODB.Connection")
connPubs.ConnectionTimeout = Session("accts_ConnectionTimeout")
connPubs.CommandTimeout = Session("accts_CommandTimeout")
connPubs.ConnectionString = "DSN=Sample;UID=sa;"
connPubs.open
  2. The Command Object: Specifying a query that is a stored procedure

    After creating and opening a connection, the application sets up a Command object by using the following steps:

    1. Set up the Command object.

    2. Specify the text of the command to execute.

    3. Specify that the command text is a stored procedure.

    The corresponding code follows:

    Set cmdPubs = Server.CreateObject("ADODB.Command")cmdPubs.CommandText = " sp_add_orders_header"
cmdPubs.CommandType = adCmdStoredProc
  3. The Parameter Object: Specifying the input and output parameters of a command

    After creating a Command object, the application sets up a Parameter object by using the following steps:

    1. Set up the Parameter object collection.

    2. Add the following input parameters to the collection:

      @piiCustomerID of type Integer with a size of 4

      @picTotalOrderPrice of type Currency with a size of 8

      @picShippingCharges of type Currency with a size of 8

      @picSalesTax of type Currency with a size of 8

    3. Add the following output parameter to the collection:

      @poiNextOrderID of type Integer with a size of 4

    The corresponding code follows:

    set p = cmdPubs.Parameters

p.Append cmdPubs.CreateParameter("@piiCustomerID",        adInteger,
adParamInput, 4)p.Append cmdPubs.CreateParameter("@picTotalOrderPrice", adCurrency,
adParamInput, 8)
p.Append cmdPubs.CreateParameter("@picShippingCharges", adCurrency,
adParamInput, 8)p.Append cmdPubs.CreateParameter("@picSalesTax",        adCurrency,
adParamInput, 8)
p.Append cmdPubs.CreateParameter("@poiNextOrderID",    adInteger,
adParamOutput, 4)
  4. The Parameter Object: Assigning values to the input parameters of a command

    The following code specifies the values to assign to the input parameters:

    cmdPubs("@piiCustomerID")        = Session("CustomerID")cmdPubs("@picTotalOrderPrice")    = Session("TotalOrderPrice")
cmdPubs("@picShippingCharges")    = Session("ShippingCharges")
cmdPubs("@picSalesTax")            = Session("SalesTax")
  5. The Command Object: Creating an active connection and executing a command

    The following code specifies the connection to use and then executes a command:

    Set cmdPubs.ActiveConnection = connPubs
cmdPubs.Execute
  6. The Parameter Object: Assigning a value from the output parameter of a command to a session variable

    The following code assigns the values of the output parameters to session variables:

    Session("OrderID") = cmdPubs("@poiNextOrderID")
  7. Clearing the Command Object

    The following code clears the contents of the Command object:

    Set cmdPubs = Nothing
  8. Clearing the Parameter Object

    The following code clears the contents of the Parameter object:

    Set p = Nothing
  9. The Command Object: Specifying a new query that is a stored procedure

    Resets the Command object by using the following steps:

    1. Specify the text of the command to execute.

    2. Specify that the command text is a stored procedure.

    The corresponding code follows:

    cmdPubs.CommandText = "sp_add_order_line_item"cmdPubs.CommandType = adCmdStoredProc
  10. The Parameter Object: Specifying the input parameters of a command

    After creating a Command object, the application sets up a Parameter object by using the following steps:

    1. Set up the Parameter object collection.

    2. Add the following input parameters to the collection:

      @piiOrderNumber of type Integer with a size of 4

      @piiLineNumber of type Integer with a size of 4

      @piiProductID of type Integer with a size of 4

      @piiQuantity of type Integer with a size of 4

      @picPrice of type Currency with a size of 4

    The corresponding code follows:

    set pp = cmdPubs.Parameterspp.Append cmdPubs.CreateParameter("@piiOrderNumber", adInteger,
adParamInput, 4)pp.Append cmdPubs.CreateParameter("@piiLineNumber", adInteger,
adParamInput, 4)pp.Append cmdPubs.CreateParameter("@piiProductID", adInteger,
adParamInput, 4)pp.Append cmdPubs.CreateParameter("@piiQuantity", adInteger,
adParamInput, 4)pp.Append cmdPubs.CreateParameter("@picPrice", adCurrency,
adParamInput, 8)
  11. Assigning the Values of Session Variables to Temporary Variables

    The following code assigns the values of session variables to temporary variables:

    aiSKProductIDs = session("aiSKProductIDs")aiSKCategoryIDs = session("aiSKCategoryIDs")
aiSKProductQuantitys = session("aiSKProductQuantitys")
aiSKProductPrices = session("aiSKProductPrices")
acSKProductNames = session("acSKProductNames")
acSKProductDescriptions = session("acSKProductDescriptions")
  12. The Parameter Object: Assigning values to the input parameters of a command

    The following code specifies the values to assign to the input parameters:

    cmdPubs("@piiOrderNumber") = Session("OrderID")cmdPubs("@piiLineNumber") = icmdPubs("@piiProductID") = aiSKProductIDs(i)
cmdPubs("@piiQuantity") = 1
cmdPubs("@picPrice") = aiSKProductPrices(i)
  13. Constructing an SQL Query from Session Variables

    The following code constructs an SQL query:

    SQL = "insert OrderLineItem "SQL = SQL & "values (" SQL = SQL & Session("OrderID") & ", "
SQL = SQL & i & ", "
SQL = SQL & aiSKProductIDs(i) & ", 0, "
SQL = SQL & aiSKProductQuantitys(i) & ", 0, "
SQL = SQL & "null, "
SQL = SQL & "null, "
SQL = SQL & aiSKProductPrices(i)
SQL = SQL & ")"
  14. Executing a Command with the Connection Object

    The following code executes a command directly through the Connection object:

    connPubs.Execute(SQL)
  15. The Command Object: Creating an active connection and executing a command

    The following code specifies the connection to use and then executes a command:

    Set cmdPubs.ActiveConnection = connPubs
cmdPubs.Execute


Cross Reference of MDAC Technologies Used

This application introduces the basic capabilities of ActiveX Data Objects (ADO) and demonstrates the following features in the modules specified:

Technology Used | Modules
The Connection Object: |
Making and opening a connection | getCategories.asp Catalog.asp Product.asp validatePassword.asp validateEmailNew.asp getAddress.asp setOrders.asp
Executing a command with the Connection object | setOrders.asp
Making and opening a connection that specifies an OLE DB Provider as the data source provider | Customize.asp
Making and opening a connection that specifies an OLE DB Provider and a Data Shaping Provider | Customize.asp
Making and opening the first of multiple connections | Status.asp
The Command Object: |
Specifying a query that is a stored procedure | Catalog.asp Product.asp validatePassword.asp validateEmailNew.asp getAddress.asp setOrders.asp Status.asp
Creating an active connection, and executing a command | validatePassword.asp validateEmailNew.asp setOrders.asp
Clearing the Command object | setOrders.asp
Specifying a query for the first of multiple connections | Status.asp Customize.asp
Specifying a query that is a stored procedure for the second of multiple connections | Status.asp
The Parameter Object: |
Specifying the input parameters of a command | Catalog.asp Product.asp validatePassword.asp validateEmailNew.asp getAddress.asp setOrders.asp Status.asp Customize.asp
Specifying the output parameters of a command | validatePassword.asp validateEmailNew.asp setOrders.asp
Assigning values to the input parameters of a command | Catalog.asp Product.asp validatePassword.asp validateEmailNew.asp getAddress.asp setOrders.asp Status.asp Customize.asp
Assigning values from the output parameters of a command | validatePassword.asp validateEmailNew.asp setOrders.asp
Clearing the Parameter object | setOrders.asp
The Recordset Object: |
Creating a Recordset Object | Customize.asp
Executing a command with the Connection object that returns a Recordset | getCategories.asp Status.asp
Opening a connection object and specifying a query that does Data Shaping and returns a hierarchical recordset | Customize.asp
Creating an active connection, and executing a command that returns a Recordset | Catalog.asp Product.asp getAddress.asp Customize.asp
The Field Object: |
Extracting data from a Recordset and assigning the data to variables | getCategories.asp getAddress.asp Status.asp Customize.asp
Navigating through a hierarchical recordset, and extracting data from the child recordset's fields to display it | Customize.asp
Extracting data from a Recordset, assigning the data to variables, and displaying the data | Catalog.asp Product.asp Status.asp
Misc: |
Adding a row to session variable arrays | addToShoppingCart.asp
Assigning the values of session variables to temporary variables | setOrders.asp
Contruct an SQL query to retrieve a hierarchical recordset using Shape commands | Customize.asp
Constructing an SQL query from session variables | setOrders.asp


getAddress.asp Module Code

The getAddress.asp module gets the customer's profile, then places output from one row of a resultset into session variables. The main steps are:

  • The Connection Object: Making and opening a connection

  • The Command Object: Specifying a query that is a stored procedure

  • The Parameter Object: Specifying the input parameter of a command

  • The Parameter Object: Assigning a value to the input parameter of a command

  • The Recordset Object: Creating an active connection and executing a command that returns a Recordset

  • The Field Object: Extracting data from a Recordset and assigning the data to session variables
  1. The Connection Object: Making and opening a connection

    This application first uses the following steps to define a connection to a database by setting up a Connection object to reference the data source:

    1. Set up the Connection object.

    2. Return the number of seconds to wait when creating a connection before stopping the attempt and returning an error specified in the global.asa module.

    3. Return the number of seconds to wait when executing a command before stopping the attempt and returning an error specified in the global.asa module.

    4. Specify the data source and user name to apply when opening the connection.

    5. Open the connection:

    The corresponding code follows:

    Set connPubs = Server.CreateObject("ADODB.Connection")
connPubs.ConnectionTimeout = Session("accts_ConnectionTimeout")
connPubs.CommandTimeout = Session("accts_CommandTimeout")
connPubs.ConnectionString = "DSN=Sample;UID=sa;"
connPubs.open
  2. The Command Object: Specifying a query that is a stored procedure

    After creating and opening a connection, the application sets up a Command by object using the following steps:

    1. Set up the Command object.

    2. Specify the text of the command to execute.

    3. Specify that the command text is a stored procedure.

    The corresponding code follows:

    Set cmdPubs = Server.CreateObject("ADODB.Command")cmdPubs.CommandText = "sp_get_customer_profile"
cmdPubs.CommandType = adCmdStoredProc
  3. The Parameter Object: Specifying the input parameter of a command

    After creating a Command object, the application sets up a Parameter object by using the following steps:

    1. Set up the Parameter object collection.

    2. Add the following input parameter to the collection:

      @ pivcEmailAddress of type Character with a size of 64

    The corresponding code follows:

    set p = cmdPubs.Parameters
p.Append cmdPubs.CreateParameter("@pivcEmailAddress", adVarChar,     adParamInput, 64)
  4. The Parameter Object: Assigning a value to the input parameter of a command

    The following code specifies the value to assign to the input parameter:

    cmdPubs("@pivcEmailAddress") = Session("cEmailAddress")
  5. The Recordset Object: Creating an active connection and executing a command that returns a Recordset

    The following code specifies the connection to use and then executes the query that returns the Recordset object:

    Set cmdPubs.ActiveConnection = connPubs
set rsPubs = cmdPubs.Execute
  6. The Field Object: Extracting data from a Recordset and assigning the data to session variables

    The following code extracts the values of the Field objects of a Recordset, and then stores the values in the session variables:

    if not rsPubs.EOF then    Session("CreditCardTypeID")        = rsPubs("CreditCardTypeID")    Session("CustomerStatus")         = rsPubs("CustomerStatus")    Session("CustomerID")             = rsPubs("CustomerID")
Session("CustomerFirstName")    = rsPubs("CustomerFirstName")
Session("CustomerLastName")        = rsPubs("CustomerLastName")
Session("eMailAddress")            = rsPubs("eMailAddress")
Session("Password")                = rsPubs("Password")
Session("CustomerAddress1")        = rsPubs("CustomerAddress1")
Session("CustomerAddress2")        = rsPubs("CustomerAddress2")
Session("CustomerCity")         = rsPubs("CustomerCity")
Session("CustomerState")         = rsPubs("CustomerState")
Session("CustomerZip")             = rsPubs("CustomerZip")
Session("CustomerPhone")         = rsPubs("CustomerPhone")
Session("CustomerFax")            = rsPubs("CustomerFax")
Session("CreditCardBankName")    = rsPubs("CreditCardBankName")
Session("CreditCardNumber")        = rsPubs("CreditCardNumber")
Session("CreditCardName")        = rsPubs("CreditCardName")
Session("CreditCardExpirationMonth")    =
rsPubs("CreditCardExpirationMonth")    Session("CreditCardExpirationYear")    =
rsPubs("CreditCardExpirationYear")end if


Catalog.asp Module Code

The Catalog.asp module retrieves the list of products by using a Command object with a stored procedure and displays the list. The main steps are:

  • The Connection Object: Making and opening a connection

  • The Command Object: Specifying a query that is a stored procedure

  • The Parameter Object: Specifying the input parameters of a command

  • The Parameter Object: Assigning a Value to the input parameter of a command

  • The Recordset Object: Creating an active connection and executing a command that returns a Recordset

  • The Field Object: Extracting data from a Recordset, assigning the data to variables, and displaying the data
  1. The Connection Object: Making and opening a connection

    This application first uses the following steps to define a connection to a database by setting up a Connection object to reference the data source:

    1. Set up the Connection object.

    2. Return the number of seconds to wait when creating a connection before stopping the attempt and returning an error specified in the global.asa module.

    3. Return the number of seconds to wait when executing a command before stopping the attempt and returning an error specified in the global.asa module.

    4. Specify the data source and user name to apply when opening the connection.

    5. Open the connection.

    The corresponding code follows:

    Set connPubs = Server.CreateObject("ADODB.Connection")
connPubs.ConnectionTimeout = Session("accts_ConnectionTimeout")
connPubs.CommandTimeout = Session("accts_CommandTimeout")
connPubs.ConnectionString = "DSN=Sample;UID=sa;"
connPubs.open
  2. The Command Object: Specifying a query that is a stored procedure

    After creating and opening a connection, the application sets up a Command object by using the following steps:

    1. Set up the Command object.

    2. Specify the text of the command to execute.

    3. Specify that the command text is a stored procedure.

    The corresponding code follows:

    Set cmdPubs = Server.CreateObject("ADODB.Command")cmdPubs.CommandText = "sp_get_products_by_category"
cmdPubs.CommandType = adCmdStoredProc
  3. The Parameter Object: Specifying the input parameters of a command

    After creating a Command object, the application sets up an input Parameter object using the following steps:

    1. Set up the Parameter object collection.

    2. Adds the following input parameters to the collection:

      @piCategoryID of type Integer with a size of 4

    The corresponding code follows:

    set p = cmdPubs.Parameters

    p.Append cmdPubs.CreateParameter("@piCategoryID", adInteger, adParamInput, 4)

  4. The Parameter Object: Assigning a value to the input parameter of a command

    The following code requests and assigns a value to the input parameter:

    cmdPubs("@piCategoryID") = Request("cCategoryID")
  5. The Recordset Object: Creating an active connection and executing a command that returns a Recordset

    The following code specifies the connection to use and then executes the query that returns the Recordset object:

    Set cmdPubs.ActiveConnection = connPubs
set rsPubs = cmdPubs.Execute
  6. The Field Object: Extracting data from a Recordset, assigning the data to variables, and displaying the data

    The following code loops through the Recordset, extracts the values of the Field objects, and displays them. The application closes the connection when it reaches the end of the Recordset.

    if rsPubs.EOF then
       %>
<TR>
<TD>
No items found
<TD>
<%
else
do until rsPubs.EOF
htmlProductID = rsPubs("ProductID")
htmlCategoryID = rsPubs("CategoryID")
htmlProductPrice = rsPubs("ProductPrice")
htmlProductName = rsPubs("ProductName")
htmlProductDescription = rsPubs("ProductDescription")
%>
<TR>
<TD><A HREF="Product.asp?iProductID=<% = htmlProductID %>">
<% = htmlProductName %></A>
<TD><% = htmlProductPrice %>
<%
rsPubs.MoveNext
Loop
rsPubs.close

end if


getCategories.asp Module Code

The getCategories.asp module gets a list of Product Categories by storing a Recordset into session variable arrays. The main steps are:

  • The Connection Object: Making and opening a connection

  • The Recordset Object: Executing a command with the Connection object that returns a Recordset

  • The Field Object: Extracting data from a Recordset and assigning the data to session variable arrays
  1. The Connection Object: Making and opening a connection

    This application first defines a connection to a database by setting up a Connection object to reference the data source. The steps taken are:

    1. Set up the Connection object.

    2. Return the number of seconds to wait when creating a connection before stopping the attempt and returning an error specified in the global.asa module.

    3. Return the number of seconds to wait when executing a command before stopping the attempt and returning an error specified in the global.asa module.

    4. Specify the data source and user name to apply when opening the connection.

    5. Open the connection

    The corresponding code follows:

    Set connPubs = Server.CreateObject("ADODB.Connection")
connPubs.ConnectionTimeout = Session("accts_ConnectionTimeout")
connPubs.CommandTimeout = Session("accts_CommandTimeout")
connPubs.ConnectionString = "DSN=Sample;UID=sa;"
connPubs.open
  2. The Recordset Object: Executing a command with the Connection object that returns a Recordset

    After creating and opening a connection, the following code executes a query that returns the number of rows in the database:

    SQL = "SELECT row_count = count(*) from Category"Set rsPubs = connPubs.Execute(SQL)iRowCount = rsPubs("row_count")
  3. The Field Object: Extracting data from a Recordset and assigning the data to session variable arrays

    The following code executes a query that returns a Recordset object. Then the application loops through the Recordset, extracts the values of the Field objects, and stores the values in session variable arrays. The application closes the connection when it reaches the end of the Recordset.

    SQL = "SELECT * from Category"Set rsPubs = connPubs.Execute(SQL)
i = 1
do until rsPubs.EOF
aipkCategoryIDs(i) = rsPubs("CategoryID")
acCategoryNames(i) = rsPubs("CategoryName")
acCategoryDescriptions(i) = rsPubs("CategoryDescription")
rsPubs.MoveNext
i = i+1
Loop
rsPubs.close
Session("aipkCategoryIDs") = aipkCategoryIDs
Session("acCategoryNames") = acCategoryNames
Session("acCategoryDescriptions") = acCategoryDescriptions


Status.asp Module Code

The Status.asp module displays the status of a customer's order by using two connections simultaneously. The main steps are:

  • The Connection Object: Making and opening the first connection

  • The Command Object: Specifying a query for the first connection

  • The Parameter Object: Specifying and assigning a value to the input parameter of the first command

  • The Command Object: Creating an active connection for the first connection

  • The Connection Object: Making and opening the second connection

  • The Command Object: Specifying a query that is a stored procedure for the second connection

  • The Parameter Object: Specifying the input parameter of the second command

  • The Recordset Object: Executing the first command that returns a Recordset

  • The Field Object: Extracting data from a Recordset and assigning the data to variables

  • The Parameter Object: Assigning a value to the input parameter of the second command

  • The Recordset Object: Executing the second command that returns a Recordset

  • The Field Object: Extracting data from a Recordset, assigning the data to variables, and displaying the data

  1. The Connection Object: Making and opening the first connection

    This application uses the following steps to define the first connection to a database by setting up a Connection object to reference the data source:

    1. Set up the Connection object.

    2. Return the number of seconds to wait when creating a connection before stopping the attempt and returning an error specified in the global.asa module.

    3. Return the number of seconds to wait when executing a command before stopping the attempt and returning an error specified in the global.asa module.

    4. Specify the data source and user name to apply when opening the connection.

    5. Open the connection.

    The corresponding code follows:

    Set connOrder = Server.CreateObject("ADODB.Connection")connOrder.ConnectionTimeout = Session("accts_ConnectionTimeout")connOrder.CommandTimeout = Session("accts_CommandTimeout")
connOrder.ConnectionString = "DSN=Sample;UID=sa;"
connOrder.open

  2. The Command Object: Specifying a query for the first connection

    After creating and opening a connection, the application sets up a Command object by using the following steps:

    1. Set up the Command object.

    2. Specify the text of the command to execute.

    3. Specify that the command text is text.

    The corresponding code follows:

    Set cmdOrder = Server.CreateObject("ADODB.Command")cmdOrder.CommandText = sqlTextcmdOrder.CommandType = adCmdText
  3. The Parameter Object: Specifying and assigning a value to the input parameter of the first command

    After creating a Command object, the application sets up a Parameter object using the following steps:

    1. Set up the Parameter object collection.

    2. Add the following input parameters to the collection:

      @piiCustomerID of type Integer with a size of 4

    3. Specify the value to assign to the input parameter.

    The corresponding code follows:

    set p = cmdOrder.Parametersp.Append cmdOrder.CreateParameter("@piiCustomerID", adInteger,
adParamInput, 4)cmdOrder("@piiCustomerID") = Session("CustomerID")
  4. The Command Object: Creating an active connection for the first connection

    The following code specifies the connection to use:

    Set cmdOrder.ActiveConnection = connOrder
  5. The Connection Object: Making and opening the second connection

    This application then uses the following steps to define the second connection to the database by setting up a Connection object to reference the data source:

    1. Set up the Connection object.

    2. Return the number of seconds to wait when creating a connection before stopping the attempt and returning an error specified in the global.asa module.

    3. Return the number of seconds to wait when executing a command before stopping the attempt and returning an error specified in the global.asa module.

    4. Specify the data source and user name to apply when opening the connection.

    5. Open the connection.

    The corresponding code follows:

    Set connLineItems = Server.CreateObject("ADODB.Connection")connLineItems.ConnectionTimeout = Session("accts_ConnectionTimeout")
connLineItems.CommandTimeout = Session("accts_CommandTimeout")
connLineItems.ConnectionString = "DSN=Sample;UID=sa;"
connLineItems.open
  6. The Command Object: Specifying a query that is a stored procedure for the second connection

    After creating and opening the second connection, the application sets up a second Command object by using the following steps:

    1. Set up the Command object.

    2. Specify the text of the command to execute.

    3. Specify that the command text is a stored procedure.

    The corresponding code follows:

    set cmdLineItems = Server.CreateObject("ADODB.Command")cmdLineItems.CommandText = "sp_get_line_item_info"cmdLineItems.CommandType = adCmdStoredProc
  7. The Parameter Object: Specifying the input parameter of the second command

    After creating the second Command object, the application sets up a Parameter object by using the following steps:

    1. Set up the Parameter object collection.

    2. Add the following input parameters to the collection:

      @piiOrderNumber of type Integer with a size of 4

    The corresponding code follows:

    set pp = cmdLineItems.Parameterspp.Append cmdLineItems.CreateParameter("@piiOrderNumber", adInteger,
 adParamInput, 4)
  8. The Recordset Object: Executing the first command that returns a Recordset

    The following code executes the first query which returns the first Recordset object:

    set rsOrder = cmdOrder.Execute
  9. The Field Object: Extracting data from a Recordset and assigning the data to variables

    The following code extracts the values of the Field objects of the first Recordset, and then stores the values in variables:

    Do until rsOrder.EOF    htmlOrderNumber                = rsOrder("OrderNumber")    htmlShippingHandlingCharges = rsOrder("ShippingHandlingCharges")    htmlTotalOrderPrice            = rsOrder("TotalOrderPrice")
htmlSalesTax                = rsOrder("SalesTax")
rsOrder.MoveNext
%>
  10. The Parameter Object: Assigning a value to the input parameter of the second command

    The following code specifies the value to assign to the input parameters of the second command:

    cmdLineItems("@piiOrderNumber")    = htmlOrderNumber
  11. The Recordset Object: Executing the second command that returns a Recordset

    The following code executes the second query and returns the second Recordset object:

    set rs = cmdLineItems.Execute
  12. The Field Object: Extracting data from a Recordset, assigning the data to variables, and displaying the data

    The following code extracts the values of the Field objects of the second Recordset, stores the values in variables, and then displays them:

  • Do until rs.EOF    htmlLineNumber            = rs("LineNumber")    htmlProductName            = rs("ProductName")    htmlItemStatusDescription = rs("ItemStatusDescription")    htmlQuantity            = rs("Quantity")    htmlLineItemPrice        = rs("LineItemPrice")    rs.MoveNext    %>    <TR>
<TD WIDTH=50>
<TD WIDTH=75 ALIGN="right"><% = htmlLineNumber %>
<TD WIDTH=240><% = htmlProductName %>
<TD WIDTH=100><% = htmlItemStatusDescription %>
<TD WIDTH=80 ALIGN="right"><% = htmlQuantity %>
<TD WIDTH=80 ALIGN="right"><% = htmlLineItemPrice %>

Customize.asp Module Code

Sets customizable properties in the Parent Categories Stack. Uses the SHAPE Provider to get a hierarchical recordset.

  • The Connection Object: Making and opening the first connection that specifies the OLE DB Provider for ODBC as the data source provider

  • The Command Object: Specifying a query that is a stored procedure for the first connection

  • The Parameter Object: Specifying the input parameters of a command for the first connection

  • The Parameter Object: Assigning a Value to the input parameter of a command for the first connection

  • The Recordset Object: Creating an active connection and executing a command that returns a Recordset for the first connection

  • The Field Object: Extracting data from a Recordset and assigning the data to a variable

  • The Connection Object: Making and opening the second connection that specifies the OLE DB Provider for ODBC as the data source provider and uses a Data Shaping Provider

  • The Recordset Object: Create a Recordset object

  • Construct an SQL Query to retrieve a hierarchical recordset using the Shape Provider

  • The Recordset Object: Open the Connection Object and specify a query that does Data Shaping and returns a Recordset for the second connection

  • The Field Object: Navigate through the child Recordset, extract data from its' Fields and display it

  1. The Connection Object: Making and opening a connection that specifies the OLE DB Provider for ODBC as the data source provider

    This application first defines a connection to a database by setting up a Connection object to reference the data source. The steps taken are:

    1. Set up the Connection object.

    2. Return the number of seconds to wait when creating a connection before stopping the attempt and returning an error specified in the global.asa module.

    3. Return the number of seconds to wait when executing a command before stopping the attempt and returning an error specified in the global.asa module.

    4. Specify the data source provider to use, the data source, and user name to apply when opening the connection.

    5. Open the connection

    The corresponding code follows:

    Set connCategories = Server.CreateObject("ADODB.Connection")
connCategories.ConnectionTimeout=Session("accts_ConnectionTimeout")
connCategories.CommandTimeout = Session("accts_CommandTimeout")
connCategories.ConnectionString="Data Provider=MSDASQL;DSN=Sample;
                                 UID=sa; pwd=;"
connCategories.open
  2. The Command Object: Specifying a query that is a stored procedure for the first connection

    After creating and opening a connection, the application sets up a Command object by using the following steps:

    1. Set up the Command object.

    2. Specify the text of the command to execute.

    3. Specify that the command text is a stored procedure.

    The corresponding code follows:

    Set cmdCategories = Server.CreateObject("ADODB.Command")
cmdCategories.CommandText = "sp_get_category_stack"
cmdCategories.CommandType = adCmdStoredProc
  3. The Parameter Object: Specifying the input parameters of a command for the first connection

    After creating a Command object, the application sets up an input Parameter object using the following steps:

    1. Set up the Parameter object collection.

    2. Add the following input parameter to the collection:

      @pi_ProductID of type Integer with a size of 4

    The corresponding code follows:

    set p = cmdCategories.Parameters
p.Append cmdCategories.CreateParameter("@pii_ProductID", adInteger,
      adParamInput, 4)
  4. The Parameter Object: Assigning a value to the input parameter of a command for the first connection

    The following code assigns a value to the input parameter from a session variable:

    cmdCategories("@pii_ProductID") = session("ProductID")
  5. The Recordset Object: Creating an active connection and executing a command that returns a Recordset for the first connection

    The following code specifies the connection to use and then executes the query that returns the Recordset object:

    Set cmdCategories.ActiveConnection = connCategories
set rsCategories = cmdCategories.Execute
  6. The Field Object: Extracting data from a Recordset and assigning the data to a variable

    The following code extracts the value of the Field object from the Recordset, and stores the value in a variable.

    iCategoryID = rsCategories("wk_category")
  7. The Connection Object: Making and opening a second connection that specifies the OLE DB Provider for ODBC as the data source provider and also uses a Data Shaping provider

    This application now defines a second connection to a database by setting up a Connection object to reference the data source. The steps taken are:

    1. Set up the Connection object.

    2. Return the number of seconds to wait when creating a connection before stopping the attempt and returning an error specified in the global.asa module.

    3. Return the number of seconds to wait when executing a command before stopping the attempt and returning an error specified in the global.asa module.

    4. Specify the data source provider to use, the data source, and user name to apply when opening the connection.

    5. Specify the provider supplying data shaping support to use.

    6. Open the connection

    The corresponding code follows:

    Set connProperties = Server.CreateObject("ADODB.Connection")
connProperties.ConnectionTimeout=Session("accts_ConnectionTimeout")
connProperties.CommandTimeout = Session("accts_CommandTimeout")
connProperties.ConnectionString="Data Provider=MSDASQL; DSN=Sample;
                                 UID=sa;pwd=;"
connProperties.Provider = "MSDataShape"
connProperties.open
  8. The Recordset Object: Create a Recordset Object

    The following code creates a Recordset object:

    Set rsProperties = Server.CreateObject("ADODB.Recordset")
  9. Construct an SQL Query to retrieve a hierarchical recordset using the Shape provider

    The following code uses the Shape provider to define a child Recordset object as the as the value of a Field object in a parent Recordset. It relates the Recordset objects from CategoryProperty and PropertyValue by PropertyID. It creates and appends a new column (chValues) to CategoryProperty. The steps taken are:

    1. Use the Shape command with a query to return the parent Recordset.

    2. Use the Shape Append command with a query to return the child Recordset.

    3. Specify the name of the new Recordset and use the Shape Relate clause to specify the common field in the parent and child Recordset.

    The corresponding code follows:

    strSQL =    "SHAPE {select * from CategoryProperty where CategoryID ="
strSQL = strSQL &    iCategoryID
strSQL = strSQL &    " }"

strSQL = strSQL &    " APPEND ({select * from PropertyValue}"

strSQL = strSQL &    " AS chValues RELATE PropertyID to PropertyID)"
  10. The Recordset Object: Open the Connection Object and specify a query that returns a Recordset for the second connection

    The following code specifies the connection to open, query string to use, and assigns the retrieved data to the Recordset object,rsProperties:

    rsProperties.Open strSQL, connProperties
  11. The Field Object: Navigate through the child Recordset, extract data from its' Fields and display it

    The following code first loops through the Parent Recordset, retrieves the appended Recordset and assigns it to rsValues, then displays three fields (PropertyID, PropertyValue, and PropertyDescription) from each row in the appended recordset.

    The corresponding code follows:

    do until rsProperties.EOF
iPropertyCount = iPropertyCount + 1
htmlPropertyName = rsProperties("PropertyName")
%>
<TD><PRE>  </PRE>
<TD><H5><% = htmlPropertyName %></H5>
<TD VALIGN="top">
<%
%>
<SELECT NAME="cboPropertyString<% = iPropertyCount %>">
<%
rsValues = rsProperties("chValues")

while not rsValues.EOF
%>
<OPTION VALUE="<%=(rsValues("PropertyID") & "&#9;" &
         htmlPropertyName & "&#9;" & rsValues("PropertyValue")) %>">
<% = rsValues("PropertyDescription") %>
<BR>
<%
rsValues.MoveNext
wend
%>
</SELECT>
<INPUT TYPE="hidden" NAME=iPropertyID<% = iPropertyCount %>     VALUE="">
<INPUT TYPE="hidden" NAME=iPropertyName<% = iPropertyCount %>     VALUE="">
<INPUT TYPE="hidden" NAME=iPropertyValue<% = iPropertyCount %>     VALUE="">
<%
rsProperties.MoveNext
Loop
rsProperties.close
rsCategories.MoveNext
Loop
rsCategories.close


Online Catalog and Order Placement Sample

The Online Catalog application is a three-tier Web application. The application uses any standard HTML browser.

The server side uses Active Server Pages to format the output and for order placement and inquiry.

This section contains the following:

  • Main Parts of the Application

  • Setting Up and Running the Online Catalog Sample Application

  • Cross Reference of MDAC Technologies Used

  • Online Catalog Sample Modules Overview

  • Detailed Module Code


addToShoppingCart.asp Module Code

The addToShoppingCart.asp module adds a product to the shopping cart by adding a row to arrays held in session variables.

Adding a Row to Session Variable Arrays

  1. Assign the session variables to temporary variables:
    aiSKProductIDs        = session("aiSKProductIDs")
aiSKCategoryIDs        = session("aiSKCategoryIDs")
aiSKProductQuantitys    = session("aiSKProductQuantitys")
aiSKProductPrices        = session("aiSKProductPrices")
acSKProductNames        = session("acSKProductNames")
acSKProductDescriptions    = session("acSKProductDescriptions")
  2. Increase row counter and redimension the temporary variables:
    jCount = CInt(iCartCount + 1)redim preserve aiSKProductIDs(jCount)        redim preserve aiSKCategoryIDs(jCount)        redim preserve aiSKProductQuantitys(jCount)    redim preserve aiSKProductPrices(jCount)
redim preserve acSKProductNames(jCount)
redim preserve acSKProductDescriptions(jCount)
  3. Add values to new row:
    aiSKProductIDs(iCartCount)            = request("iProductID")
aiSKCategoryIDs(iCartCount)        = request("iCategoryID")
aiSKProductQuantitys(iCartCount)        = htmlQuantity
aiSKProductPrices(iCartCount)        = request("iProductPrice")
acSKProductNames(iCartCount)        = request("cProductName")
acSKProductDescriptions(iCartCount)    = request("cProductDescription")
  4. Assign the temporary variables to the session variable arrays:
    session("aiSKProductIDs")            = aiSKProductIDs
session("aiSKCategoryIDs")            = aiSKCategoryIDs
session("aiSKProductQuantitys")        = aiSKProductQuantitys
session("aiSKProductPrices")        = aiSKProductPrices
session("acSKProductNames")        = acSKProductNames
session("acSKProductDescriptions")    = acSKProductDescriptions


Running the Online Catalog Sample Application

Setting Up and Running the Online Catalog Sample Application

The Online Catalog Sample Application uses any major web browser for its client piece, IIS as the Web Server, and SQL Server as the database.

The following sections describe the steps necessary to set up the environment for running the sample application:

  • Hardware Requirements

  • Setup SQL Server Database

  • Load Web Pages onto Server

  • Setup Web Server

  • Run the Sample Application

  • Troubleshooting

NOTE: These instructions are designed to get the sample applications up and running: they should not be used as a guide to good database practices in a production environment.

Hardware Requirements You need to verify that you meet the following hardware requirements:

  • Server machine with the following software installed and configured:
    • Windows NT 4.0

    • Windows NT Service Pack 3

    • Internet Information Service 4.0 installed from the NT Option Pack

    • SQL Server 6.5

    • ADO 2.0
  • Client machine with a major browser installed (IE 3.0 or 4.0, Netscape 3.0 or 4.0)

    NOTE: The SQL Server and Web Server will exist on the same machine, even though in a production environment exposed to the Internet you would probably have your SQL Server on a separate machine behind a fire wall.

Setup SQL Server Database

This section outlines how to run the self-extracting DBSetup.exe file and the commands used to create the physical directories for your database, the database itself, the tables and stored procedures, and then loads the domain table data.

NOTE: The MDAC SDK installs two self-extracting exe files used to setup an SQL Server database and an IIS server with the files necessary to run this sample. When you run these self-extracting exe files, they decompress a set of files into the directory “MDAC Samples” on your C: drive. These files, DBSetup.exe and WebSetup.exe, are located where you installed the MDAC SDK in the Samples\MDAC directory. The default is C:\MSDASDK\Samples\MDAC.

The DBSetup.exe file sets up the SQL Server database. You need to extract this file on the machine running SQL Server, or on the client machine with the SQL Server client software installed.

The Websetup.exe file sets up the IIS server with the sample web files. You need to run this file on the system running the IIS server.

If the machine running either SQL Server or the IIS server is different than the machine you installed the MDAC SDK on, simply copy the appropriate exe to that machine.

  1. If needed, copy the file DBSetup.exe to the machine running SQL Server, or a machine that has the client SQL Server software installed.

  2. Run the DBSetup.exe file. The program will extract the database setup files to the directory “C:\MDAC Samples\Database” In addition, the program creates several subdirectories underneath this directory. You can remove these files and subdirectories after the database has been setup.

  3. Open an MS DOS window and change to the directory where you extracted the database setup files. Change to the bat subdirectory under “C:\MDAC Samples\Database”. This directory contains all the batch files to run. These batch files use the following parameters:
    • ServerName specifies the server name

    • AdminUserID specifies the administrative user id

      This is typically “sa” or a user id with administrative privileges.

    • Password specifies the user password
  4. Create the database devices by entering the following in the MS DOS window:
    makedev ServerName AdminUserID Password

    Two acknowledgement messages appear: Data device created, and Log device created. If you get the following error message: “The name specified is not recognized as an internal or external command, operable program or batch file”, it could mean that SQL Server, or the client software, is not installed propertly on your system. In order to complete properly, the SQL Server software ISQL.EXE must be available on the system.

    This step creates the directory MDACsql off the root c:\driver with the subdirectories data and logs. The data device is 10 mg in size, the logs device is 5 meg.

    Any errors encountered are added to a log report. You can identify these files by the .LOG extension with the same name as the command used (in this case MAKEDEV.LOG). Check this file to see if any errors occurred.

    NOTE: If you want to create these devices somewhere else, you need to modify the makedev.sql file. Search for "@vc_device_UNC" which defines the paths of the devices.

  5. Create the database by entering the following in the MS DOS window:
    createdb ServerName AdminUserID Password

    Several acknowledgement messages appear. Check CREATEDB.LOG for any errors.

  6. Set up the contents of the database by entering the following in the MS DOS window:
    setupdb ServerName AdminUserID Password

    This step does the following:

    • Creates the tables and should complete with no messages or errors

    • Creates the stored procedures and should complete with “Creating stored Procedures” message and no errors

    • Creates database logons and users with their permissions set, and should complete with several acknowledgement messages, and no errors

    • Loads tables with data and should complete with several acknowledgement messages, and no errors

Web Server Setup

This section outlines how to run the self-extracting Websetup.exe file to extract the sample web pages, and how to set up your IIS Web server to run the samples.

  1. If needed, copy the file WebSetup.exe to the machine running your IIS 4.0 server.

  2. Run the WebSetup.exe file. The program will extract the web pages to the directory “C:\MDAC Samples\OnlineCatalog”. After they are extracted, if you wish to move them to a different directory, you can simple copy the directory elsewhere.

  3. Start Internet Service Manager (Start -> NT 4.0 Option Pack -> Microsoft Internet Information Server -> Internet Service Manager).

  4. In the window that appears, click on the Internet Information Server node to open it.

  5. Click on the [Server Name] node to open it.

  6. Enable Anonymous Access:
    1. Right-click on Default Web Site and select Properties.

    2. Click the Directory Security tab in the dialog box.

    3. Click the Edit button in the Anonymous Access and Authentication Control panel.

    4. Click on the Allow Anonymous Access check box, then click the OK button.

    5. Click the OK button to exit the Properties dialog Box.
  7. Set the virtual directories for the sample Order Entry application:
    1. Right-click on Default Web Site -> New -> Virtual Directory.

    2. In the Alias to be used to access virtual directory text box, enter:
      OnlineCatalog

      Click the Next button.

    3. Enter the physical path where the extracted files reside. The extract program places them in “C:\MDAC Samples\OnlineCatalog”. If you copied them elsewhere, specify the new location. Or you can find and select it by clicking the Browse button, and click NEXT.

    4. Click on the Allow Access check boxes for Read, Script, and Execute permission. Click the Finish button.
  8. Set the Default Document:
    1. Right-click on Default Web Site and select Properties.

    2. Click the Document tab in the dialog box.

    3. Click on the Enable Default Document check box. Click the Add Button and enter Default.asp (if not already present). Click the OK button.
  9. Restart the W3 Service:
    1. Select Default Web Site.

    2. Click the Stop icon (the black square in the tool bar).

    3. When the Service stops, the black square is no longer bold, click on the Start icon, (the triangle).

Run the Sample App

To run the application, start up your browser and type in the following:

http://ServerName/OnlineCatalog

The Sample Application's homepage appears. All the Domain tables have data entered, except for Customers and Orders. You can now start browsing the Catalog, entering Customer Profile information, making Orders, and checking Order Status.

Troubleshooting

You may want to undo the installation for any number of reasons: insufficient disk space, changing path names, or interrupted installation. In all cases, follow the steps below. Since you may be backing out an incomplete install, start with the last step that you got to.

  1. Using the Microsoft Management Console, delete the OnlineCatalog virtual directory under the “Default Web Site Node”.

  2. Using the Microsoft Management Console, stop the Web Service and restart it again: this will release any hold the IIS Server had on the file system directories and files where the web pages reside;

  3. Start Enterprise Manager (Start -> Programs -> SQL Server 6.5 -> Eneterprise Manager).

  4. Open the appropriate server by clicking on its name.

  5. Delete the Sample database:
    1. Open the Databases node by clicking on it.

    2. Right click on it, and click Refresh

    3. Delete the database by right clicking on the database name (MDAC20Samples), and selecting Delete.
  6. Delete the database logical devices:
    1. Open the Database Devices node.

    2. Right click on the Database Devises tab and select Refresh. If the ADO20Samples_log1 file or ADO20Samples_data1 file exists, select and delete them.
  7. Delete the physical files that make up the Database Devices by starting Windows NT Explorer and deleting c:\MDACsql. This deletes the data and logs subdirectories.

  8. Delete the sample logon:
    1. Open the Logins node by clicking on it.

    2. Right-click SampleUser and select Drop.
  9. Delete the directory “C:\MDAC Samples\Database”. Do likewise with the web pages directory “C:\MDAC Samples\OnlineCatalog” (make sure any DOS boxes that might be referencing these directories are closed. This deletes all scripts decompressed from the exe files.

You are now ready to make any needed changes to the scripts (device or directory names, etc), and repeat the install process.


Product.asp Module Code

The Product.asp module retrieves and displays the information of one product. The main steps are:

  • The Connection Object: Making and opening a connection

  • The Command Object: Specifying a query that is a stored procedure

  • The Parameter Object: Specifying the input parameters of a command

  • The Parameter Object: Assigning a value to the input parameter of a command

  • The Recordset Object: Creating an active connection and executing a command that returns a Recordset

  • The Field Object: Extracting and displaying data from a Recordset
  1. The Connection Object: Making and opening a connection

    This application first uses the following steps to define a connection to a database by setting up a Connection object to reference the data source:

    1. Set up the Connection object.

    2. Return the number of seconds to wait when creating a connection before stopping the attempt and returning an error specified in the global.asa module.

    3. Return the number of seconds to wait when executing a command before stopping the attempt and returning an error specified in the global.asa module.

    4. Specify the data source and user name to apply when opening the connection.

    5. Open the connection.

    The corresponding code follows:

    Set connPubs = Server.CreateObject("ADODB.Connection")
connPubs.ConnectionTimeout = Session("accts_ConnectionTimeout")
connPubs.CommandTimeout = Session("accts_CommandTimeout")
connPubs.ConnectionString = "DSN=Sample;UID=sa;"
connPubs.open
  2. The Command Object: Specifying a query that is a stored procedure

    After creating and opening a connection, the application sets up a Command object by using the following steps:

    1. Set up the Command object.

    2. Specify the text of the command to execute.

    3. Specify that the command text is a stored procedure.

    The corresponding code follows:

    Set cmdPubs = Server.CreateObject("ADODB.Command")cmdPubs.CommandText = "sp_get_product"
cmdPubs.CommandType = adCmdStoredProc
  3. The Parameter Object: Specifying the input parameters of a command

    After creating a Command object, the application sets up a Parameter object by using the following steps:

    1. Set up the Parameter object collection.

    2. Add the following input parameter to the collection:

      @ piiProductID of type Integer with a size of 4

    The corresponding code follows:

    set p = cmdPubs.Parameters
p.Append cmdPubs.CreateParameter("@piiProductID", adInteger,     adParamInput, 4)
  4. The Parameter Object: Assigning a Value to the input parameter of a command

    The following code specifies the value to assign to the input parameter:

    cmdPubs("@piiProductID") = Request("iProductID")
  5. The Recordset Object: Creating an active connection and executing a command that returns a Recordset

    The following code specifies the connection to use and then executes the query that returns the Recordset object:

    Set cmdPubs.ActiveConnection = connPubs
set rsPubs = cmdPubs.Execute
  6. The Field Object: Extracting and displaying data from a Recordset

    The following code loops through the Recordset, displays a record, and closes the connection when it reaches the end of the Recordset:

    if rsPubs.EOF then
       %>
<TR>
<TD>
No items found
<TD>
<%
else
do until rsPubs.EOF
htmlProductID = rsPubs("ProductID")
htmlCategoryID = rsPubs("CategoryID")
htmlProductPrice = rsPubs("ProductPrice")
htmlProductName = rsPubs("ProductName")
htmlProductDescription = rsPubs("ProductDescription")
<TABLE>        <TR>            <TD><H1><% = htmlProductName %></H1>
<TD><H2><FONT COLOR="RED">$<% = htmlProductPrice %>
</FONT><H2>        <TR>            <TD><H5>Enter Quantity:            <INPUT TYPE="Text" NAME=cQuantity SIZE=3 VALUE=1></H5>        <TR>
<TD><H4><% = htmlProductDescription %></H4>
<BR>
<BR>
<%
rsPubs.MoveNext
Loop
rsPubs.close
end if
%>


Main Parts of the Online Catalog Sample Application

The Catalog application contains the following main parts:

  • Product Catalog description

  • Customer Profile Information description

  • Order Entry and Inquiry description

Product Catalog

The Product Catalog enables the customer to browse the products available for purchase. While browsing, the customer can mark a product to order and specify the quantity desired. When a customer profile exists for the customer, the catalog automatically customizes itself based on this profile information.

Customer Profile Information

The application maintains customer information, such as the customer’s address, phone, and billing information, within the database. Plus, the customer profile may contain information about the customer’s product preferences or areas of interest, which the application uses to customize the online catalog based on the customer viewing it.

Order Entry and Inquiry

The sample uses the order entry system when the customer wants to purchase a product. If the customer does not have a customer profile, a Customer Profile Information page appears for the customer to complete. After completing the page, the customer can change the shipping address and the quantity and shipping options for the order. When the customer completes the order entry, the sample assigns an order number to the customer for future reference.

The sample allows the customer to inquire about previous orders made and find out the status of their pending orders.


Detailed Module Code

This section goes into more detail about the data access technologies used in the following modules:

  • getCategories.asp Module Code

  • Catalog.asp Module Code

  • Product.asp Module Code

  • addToShoppingCart.asp Module Code

  • validatePassword.asp Module Code

  • validateEmailNew.asp Module Code

  • getAddress.asp Module Code

  • setOrders.asp Module Code

  • Status.asp Module Code

  • Customize.asp Module Code