⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vcg22.htm

📁 Visual C++与数据库的连接经典实例
💻 HTM
📖 第 1 页 / 共 5 页
字号:

         Name                                   Type                       Size

         Category ID                            Number (Long)                 4

                  Allow Zero Length:         False

                  Attributes:                Fixed Size, Auto-Increment

                  Collating Order:           General

                  Column Hidden:             False

                  Column Order:              Default

                  Column Width:              1110

                  Description:               Number automatically assigned 

                                                           to new category.

                  Ordinal Position:          0

                  Required:                  False

                  Source Field:              Category ID

                  Source Table:              Categories

         Category Name                          Text                         15

                  Allow Zero Length:         False

                  Attributes:                Variable Length

                  Collating Order:           General

                  Column Hidden:             False

                  Column Order:              Default

                  Column Width:              1395

                  Description:               Name of food category.

                  Ordinal Position:          1

                  Required:                  True

                  Source Field:              Category Name

                  Source Table:              Categories

         Description                            Memo                          -

                  Allow Zero Length:         False

                  Attributes:                Variable Length

                  Collating Order:           General

                  Column Hidden:             False

                  Column Order:              Default

                  Column Width:              4380

                  Ordinal Position:          2

                  Required:                  False

                  Source Field:              Description

                  Source Table:              Categories

         Picture                                OLE Object                    -

                  Allow Zero Length:         False

                  Attributes:                Variable Length

                  Collating Order:           General

                  Column Hidden:             False

                  Column Order:              Default

                                                    Thursday, January 18, 1996

Table: Categories                                                      Page: 2

                  Column Width:              1470

                  Description:               A picture representing 

                                                        the food category.

                  Ordinal Position:          3

                  Required:                  False

                  Source Field:              Picture

                  Source Table:              Categories

Relationships

         Reference1_Products

                           Categories                           Products

                    Category ID                1        Category ID

                  Attributes:                Enforced

                  Attributes:                One-To-Many

Table Indexes

         Name                                     Number of Fields

         Category Name                            1

                  Clustered:                 False

                  Distinct Count:            8

                  Foreign:                   False

                  Ignore Nulls:              False

                  Name:                      Category Name

                  Primary:                   False

                  Required:                  False

                  Unique:                    True

                  Fields:                    Category Name, Ascending

         PrimaryKey                               1

                  Clustered:                 False

                  Distinct Count:            8

                  Foreign:                   False

                  Ignore Nulls:              False

                  Name:                      PrimaryKey

                  Primary:                   True

                  Required:                  True

                  Unique:                    True

                  Fields:                    Category ID, Ascending

                                                    Thursday, January 18, 1996

Database: I:\Database Developers Guide with Visual C++ 4\Source        Page: 3

CD\NorthWind 7.mdb

Properties

AccessVersion:         06.68                          Build:                 4

Collating Order:       General                        Def. Updatable:     True

Query Timeout:         60                             Records Affected:      0

Transactions:          True                           Version:             3.0

User Permissions

         admin

         User

         User1

Group Permissions

         Admins

         Users

                                                    Thursday, January 18, 1996

Relationships: All                                                     Page: 4

Relationships

         Reference

                            Customers                            Orders

                    Customer ID                1        Customer ID

                  Attributes:                Enforced, Cascade Updates

                  Permissions:               One-To-Many

         Reference1

                            Suppliers                           Products

                    Supplier ID                1       Supplier ID

                  Attributes:                Enforced

                  Attributes:                One-To-Many

         Reference1_Products

                           Categories                           Products

                    Category ID                1       Category ID

                  Attributes:                Enforced

                  Attributes:                One-To-Many

         Reference2

                            Products                          Order Details

                    Product ID                 1       Product ID

                  Attributes:                Enforced

                  Attributes:                One-To-Many

                                                    Thursday, January 18, 1996

Relationships: All                                                     Page: 5

         Reference3

                            Shippers                             Orders

                                               1     

                    Shipper ID                          Ship Via

                  Attributes:                Enforced

                  Attributes:                One-To-Many

         Reference4

                             Orders                           Order Details

                                               1     

                    Order ID                            Order ID

                  Attributes:                Enforced, Cascade Deletes

                  Attributes:                One-To-Many

         Reference5

                            Employees                            Orders

                    Employee ID                1       Employee ID

                  Attributes:                Enforced

                  Attributes:                One-To-Many</FONT></PRE>

<P>Of course, you can simply print the report generated by the Database Documentor using a high-quality printer. Figure 22.6 shows the first page of the report in Access. The actual printout is identical to the screen image.

<BR>

<P><B><A HREF="22vcg06.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/22vcg06.gif">Figure 22.6. The first page from Database Documentor.</A></B>

<BR>

<BR>

<A NAME="E69E274"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Using Access's Database Documentor to Document Databases</B></FONT></CENTER></H4>

<BR>

<P>Access 2's Database Documentor lets you create tables you can use to develop a data-dictionary application. The Database Documentor is located under Tools | Analyze | Documentor in Access 7.

<BR>

<P>To use the Database Documentor to create information from which you can build a data dictionary, follow these steps:

<BR>

<OL>

<LI>Launch Access's Database Documentor by selecting Tools | Analyze | Documentor. You will see the Database Documentor dialog, shown in Figure 22.7. If you want to, you can use this dialog to display a list of all the objects in the currently open database by changing the Object Type selection.

<BR>

<BR><B><A HREF="22vcg07.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/22vcg07.gif">Figure 22.7. Database Documentor's form displaying tables in the database.</A></B>

<BR>

<BR>

<LI>Click the Select All button to select all the tables, and then click the OK button to display the results of Database Documentor. You can add the tables to any Access database file, including the database that you're analyzing. In this case, select NorthWind.MDB and click the OK button to start the analysis.

<BR>

<BR>

<LI>After a period of intense disk activity, you will see the results of Database Documentor. When you have finished viewing the results (and printing, if desired), you can simply close the Database Documentor window.

<BR>

<BR>

</OL>

<BR>

<A NAME="E69E275"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Documenting Databases Created with CASE Tools</B></FONT></CENTER></H4>

<BR>

<P>If you create your Access or client-server databases with a computer-aided software engineering (CASE) tool, such as Asymetrix's InfoModeler, you can expand the contents of your data dictionary to include descriptions of the underlying object types, fact types, and constraints from which the design of the database is created. Using InfoModeler to create Access databases is one of the subjects of Chapter 4, &quot;Optimizing the Design of Relational Databases.&quot; Figure 22.8 shows part of one page (Advertising) of the database diagram of the MailOrder tutorial application that accompanies InfoModeler version 1.5.

<BR>

<P><B><A HREF="22vcg08.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/22vcg08.gif">Figure 22.8. A part of the Advertising element of InfoModeler 1.5's MailOrder tutorial application.</A></B>

<BR>

<P>All the information about object types, fact types, and constraints is stored in a repository, a database that contains information about databases. Using InfoModeler's reporting features, you can create a report that you can integrate with a data dictionary for the database that InfoModeler creates for you. A part of the report that InfoModeler creates for the Advertising element of the MailOrder application is shown in Figure 22.9. (The entire report is eight pages long.)

<BR>

<P><B><A HREF="22vcg09.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/22vcg09.gif">Figure 22.9. Part of an InfoModeler report in print preview mode.</A></B>

<BR>

<P>After you've completed your database design, InfoModeler creates the database for you. If you have the retail version of Access, you can create an Access database. Otherwise, InfoModeler creates the ANSI (generic) SQL statements required to build the database. Figure 22.10 shows Access's design-mode view of the CoopAd table. InfoModeler creates the CoopAd table from the information stored in the repository that underlies the database diagram shown in Figure 22.8 and that is described in the report file, part of which appears in Figure 22.9.

<BR>

<P><B><A HREF="22vcg10.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/22vcg10.gif">Figure 22.10. An Access table in the MAIL_ORD.MDB database created by InfoModeler.</A></B>

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>NOTE</B>

<BR>

<BR>One of the advantages of using a CASE tool such as InfoModeler is that you can include the table and field descriptions in your data dictionary. The table and field descriptions originate in InfoModeler, not in Access, so the values of the Description property of the Table and Field objects that InfoModeler creates are available to your data dictionary application. You'll need to dig a bit, however, to obtain the data from Raima's Vista database, which is used as InfoModeler's repository.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<BR>

<A NAME="E69E276"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Using Total Access to Create a Data Dictionary</B></FONT></CENTER></H4>

<BR>

<P>Financial Modeling Specialists (FMS), Inc.'s Total Access is an Access 2 library database that you attach to the retail version of Access using a setup program supplied by FMS. FMS's Total Access provides comprehensive documentation and analysis of Access databases, not just the simple listing of some table and field properties that Access's Database Documentor generates. Total Access includes a large number of built-in reports that you can use to print a complete description of the database, including a detailed data dictionary for Table and Field objects. You also can modify Total Access's reports to suit your own requirements.

<BR>

<P>Total Access generates thorough documentation for all Access database objects. Figure 22.11 shows Total Access's Document Form, which corresponds to the Database Analyzer, with NorthWind.MDB as the active database. If you're using Access databases only with Visual C++ applications, you'll only be able to take advantage of Total Access's Table and Queries documentation features.

<BR>

<P><B><A HREF="22vcg11.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/22vcg11.gif">Figure 22.11. Total Access's main analysis window.</A></B>

<BR>

<P>Start Total Access by selecting File | Add-ins | Total Access Analyzer. After you've selected the objects you want to document, click the Next button and wait while Total Access does its job. A progress monitor shows you how much of the documentation process has been completed. Preparing the documentation for the 125 objects of NorthWind.MDB (everything in the NorthWind.MDB database) took about 10 minutes on a Pentium server and a Pentium 90 computer with 32M of RAM and a total of 6 gigabytes of high-speed SCSI fixed-disk space. If you limit your documentation to tables and queries, for example, this processing time will be less.

<BR>

<P>Figure 22.11 shows all objects contained in NorthWind.MDB following an analysis.

<BR>

<P>After Total Access builds the required tables, creating and printing reports such as the Table Dictionary shown in Figure 22.12 is a fast process.

<BR>

<P><B><A HREF="22vcg12.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/22vcg12.gif">Figure 22.12. Total Access's Table Dictionary report in print preview mode.</A></B>

<BR>

<P>One of the principal benefits of using Total Access for creating data dictionaries is that you can open TA2DOC_C.MDA as a database in your Visual C++ data dictionary generator. Total Access creates one or more internal tables with a TA2_ prefix for each class of Access database object. Figure 22.13 shows part of the TA2_OutputFields table for the NorthWind.MDB database. Total Access includes the Description properties of Table and Field objects in its tables and reports. FMS obtains this information by opening each Table object in design mode and reading the value of the property.

<BR>

<P><B><A HREF="22vcg13.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/22vcg13.gif">Figure 22.13. One of the tables created by Total Access to document Access Table objects.</A></B>

<BR>

<BR>

<A NAME="E68E114"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Creating Manuals for Your Database Applications</B></FONT></CENTER></H3>

<BR>

<P>Despite the almost universal reluctance of software users to refer to printed manuals, your application isn't complete until you've written its user documentation. Relying on users to read or print the README.TXT file that accompanies your application before installing it is seldom an effective approach. Most users will simply insert your distribution disk 1 in a drive, choose File | Run from Program Manager, type a:\setup or b:\setup in the Command Line text box, and then click the OK button. If this entry doesn't work, the user next tries a:\install or b:\install. When this fails, he might read the &quot;Installation&quot; section of your documentation. It's more likely, however, that the user will call you to find out what's wrong. Microsoft reports that the vast majority of the questions posed to members of the Product Support Staff for Access can be answered in either README.TXT or the documentation that accompanies Access. The same is undoubtedly true for Visual C++.

<BR>

<P>Of course, you could be smart and include installation instructions on the label of the first disk of

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -