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

📄 vcg09.htm

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

<HEAD>

<TITLE>vcg09.htm </TITLE>

<LINK REL="ToC" HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/index.htm">

<LINK REL="Index" HREF="htindex.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/htindex.htm">

<LINK REL="Next" HREF="vcg10.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/vcg10.htm">

<LINK REL="Previous" HREF="vcgp3.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/vcgp3.htm"></HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">

<A NAME="I0"></A><P ALIGN=CENTER>

<A HREF="vcgp3.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/vcgp3.htm" TARGET="_self"><IMG SRC="blanprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/blanprev.gif" WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="Previous Page"></A>

<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/index.htm" TARGET="_self"><IMG SRC="blantoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/blantoc.gif" WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="TOC"></A>

<A HREF="vcg10.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/vcg10.htm" TARGET="_self"><IMG SRC="blannext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/blannext.gif" WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="Next Page"></A>


<HR ALIGN=CENTER>

<P>

<UL>

<UL>

<UL>

<LI>

<A HREF="#E68E54" >Organizing the Data Behind a Decision-Support Application</A>

<UL>

<LI>

<A HREF="#E69E162" >Specifying the Datasources</A>

<UL>

<LI>

<A HREF="#E70E50" >Determining the Level of Detail Required</A>

<LI>

<A HREF="#E70E51" >Maintaining Performance and Data Consistency with Rollups</A></UL>

<LI>

<A HREF="#E69E163" >Query Strategies</A>

<UL>

<LI>

<A HREF="#E70E52" >Persistent Versus Impersistent Queries</A>

<LI>

<A HREF="#E70E53" >Designing Rollup Queries</A>

<LI>

<A HREF="#E70E54" >Implementing Ad Hoc Queries</A></UL></UL>

<LI>

<A HREF="#E68E55" >Designing the User Interface</A>

<UL>

<LI>

<A HREF="#E69E164" >Optimizing Application Usability</A>

<UL>

<LI>

<A HREF="#E70E55" >Striving for Simplicity</A>

<LI>

<A HREF="#E70E56" >Maintaining Consistency</A></UL>

<LI>

<A HREF="#E69E165" >Identifying Toolbar Button Functions</A></UL>

<LI>

<A HREF="#E68E56" >Creating and Using Toolbars</A>

<UL>

<LI>

<A HREF="#E69E166" >Obtaining and Modifying Button Bitmaps</A>

<UL>

<LI>

<A HREF="#E70E57" >Using the Image Editor Application to Create Button Bitmaps</A>

<LI>

<A HREF="#E70E58" >Generating Bitmaps with Desktop Publishing Packages</A></UL></UL>

<LI>

<A HREF="#E68E57" >Displaying Detail Data with the WinWidgets HGrid Control</A>

<LI>

<A HREF="#E68E58" >Summary</A></UL></UL></UL>

<HR ALIGN=CENTER>

<A NAME="E66E25"></A>

<H1 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>- 9 -</B>

<BR><B>Designing a Decision-Support Application</B></FONT></CENTER></H1>

<BR>

<P>It's likely that your first production-database application that uses Visual C++ will be used for decision-support purposes. Industry sources estimate that decision-support applications constitute 75 percent or more of all of the database applications in use today. Also, decision-support applications are often easy to write and maintain. When you create a decision-support application for use with an existing relational database, you need not be concerned with database design, maintaining referential and domain integrity, or concurrency problems. (You do, however, need to take consistency issues into account if you're summarizing data.)

<BR>

<P>The purpose of a decision-support application is to transform raw data into useful information. Your primary task is to provide the users of your application with a simple, straightforward method of obtaining the data they need. This chapter begins by discussing how to organize the data you're converting to useful information with decision-support applications. It also discusses designing the user interface to make your application easy to understand and provides examples of forms that display information in graphical and tabular format. Finally, this chapter reviews examples of the Visual C++ code needed to create the graph, chart, and grid objects that display selected information to the user. Visual C++ doesn't support these display objects directly, so you will learn about a number of alternative add-in products that may be used for this purpose.

<BR>

<BR>

<A NAME="E68E54"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Organizing the Data Behind a Decision-Support Application</B></FONT></CENTER></H3>

<BR>

<P>The objective of most of today's decision-support applications is to replace printed reports with on-screen presentations of information. A successful decision-support application supplies &quot;Information at Your Fingertips&quot; (a Microsoft-trademarked corporate slogan). For mid-level managers and below, the <I>video display unit</I> (VDU) of a PC is the most common presentation platform. At the vice-presidential and higher rungs of the corporate ladder, the information often is displayed on large-screen or projection video systems acting as a VDU for one PC in a conference setting.

<BR>

<BR>

<A NAME="E69E162"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Specifying the Datasources</B></FONT></CENTER></H4>

<BR>

<P>Typical relationships of datasources and information systems for a typical manufacturing company appear in the hierarchical structure shown in Figure 9.1. Data-entry and transaction-processing activities primarily are confined to the lowest level of the hierarchy, operational databases. (The operational database level of the hierarchy often is called &quot;the trenches.&quot;) The levels above the operational databases involve little or no data entry; these upper levels in the hierarchy are referred to as <I>information systems</I> (IS) or <I>management information </I><I>systems</I> (MIS). Figure 9.1 divides the information systems category into functional information systems at the directorate and vice-presidential level and planning and forecasting information systems that are used by top management and corporate staff.

<BR>

<P><B><A HREF="09vcg01.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/09vcg01.gif">Figure 9.1. The hierarchy of information systems and databases for a manufacturing firm.</A></B>

<BR>

<P>Depending on the size of the company and the type of computer hardware the firm uses, the operational databases may be located in a centralized mainframe system or distributed across several database servers in a client-server RDBMS environment. Combinations of mainframe and client-server environments are common for firms that are in the process of downsizing and distributing their operational databases. A small manufacturing firm might have all its operational databases in the form of multiple .DBF files that reside on a single file server.

<BR>

<P>If you're developing database applications for a firm with $10 million or more in annual sales, be prepared to deal with the connectivity issues raised by a wide variety of network operating systems and database management systems, including <I>legacy</I> (a synonym for &quot;obsolete&quot; among proponents of client-server RDBMSs) network and hierarchical DBMS. It's not uncommon for developers of database front ends to spend more time solving connectivity problems, both DBM- and network-related, than they spend designing, coding, and testing the entire front-end application.

<BR>

<P>You also might need to integrate data from online datasources into your database front-end application. Credit information from Dun and Bradstreet and TRW, stock prices from the Dow Jones News Service, and real estate transaction data from Damar are just a few of the uses for the data communication features of Visual C++. Another nontraditional datasource that you might need to incorporate in your applications is the CD-ROM. Virtually all the 1990 census data is available from the U.S. Bureau of the Census in .DBF format on CD-ROMs. Fortunately, ODBC lets developers work with .DBF format files.

<BR>

<BR>

<A NAME="E70E50"></A>

<H5 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Determining the Level of Detail Required</B></FONT></CENTER></H5>

<BR>

<P>Before the advent of the RDBMS and client-server computing technology, the principal source of functional information, as well as planning and forecasting information, was a multitude of printed reports. Each report was the product of a batch operation that required a program, usually written in COBOL, to execute the Embedded SQL or other instructions that create a formatted report. In many cases, reports were created with more than the optimal level of detail because of a lack of programming resources to write, test, and deploy production programs to summarize the data. The capability of users of client applications to create their own ad hoc queries with whatever degree of detail they desire is the driving force behind the front-end application generator market. Generally, a management report that is more than two pages in length probably presents too much detail.

<BR>

<P>Unless you're dealing with data that has been <I>rolled up</I> (the subject of the next section), your decision-support front-end application will be accessing tables in operational databases. The level of detail you provide in a decision-support application usually varies inversely with the position of the users in the organizational hierarchy. As you progress upward in the corporate &quot;food chain,&quot; tabular data gives way to graphs and charts for trend analysis, and the frequency of reporting slows from daily to monthly. Here are the three basic categories of decision-support applications:

<BR>

<UL>

<LI><I>Executive summaries</I> and planning information consist of graphs and charts that depict financial performance versus internal projections, versus prior fiscal periods, and often versus the results reported by competitors. This category of report is the most likely to require integration of data from online sources operated by data utilities, such as Dialog Information Services, or from firms that specialize in providing online econometric data.

<BR>

<BR>

<LI><I>Functional summaries</I>, such as reports of orders for the director of sales or daily cash-flow reports from the director of finance, are usually run weekly. At the directorate level, tabular data is the rule. The data from the directors' reports usually is consolidated into monthly reports issued at the vice-presidential level. Graphs compare current operating results with recent historical data, usually for a one-year period or shorter.

<BR>

<BR>

<LI><I>Operational data summaries</I> are required by supervisory personnel to evaluate day-to-day performance at the departmental or regional level. Credit managers need real-time access to the payment histories of customers placing new orders. Exception-reporting applications that are used on the shop floor, such as applications that identify parts shortages or quality control problems, may need to run on an hourly or shift basis. Tabular formats, rather than graphic presentations, are most common at the operational level.

<BR>

<BR>

</UL>

<P>Figure 9.2 shows the layers of information that constitute typical marketing decision-support applications corresponding to the three categories in the preceding list. The executive summary for the vice president of marketing consolidates sales of all products in all regions. The functional summary for the director of sales includes sales of a particular product line in all regions. The operational data viewed by the regional sales manager reports sales in one region for all products.

<BR>

<P><B><A HREF="09vcg02.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/09vcg02.gif">Figure 9.2. Levels of information detail in summary and operational decision-support applications.</A></B>

<BR>

<P>One of the principal objections of management personnel to MIS reports, whether displayed online or in the form of computer printouts, is excessive detail. If you use a 9-point MS Sans Serif font with a tightly spaced Visual C++ list box, you can display several times as much data on a VDU as is possible with a character-based DOS application. Running at higher resolutions (such as 1024x768) allows a large amount of data to be presented to the user. You have similar potential with today's laser printers. For management, it's the aggregate data that is important, together with exception highlighting. If you need to provide one or two levels of detail behind the summary data, first offer the detail behind the exceptions and then make additional detail information an option.

<BR>

<BR>

<A NAME="E70E51"></A>

<H5 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Maintaining Performance and Data Consistency with Rollups</B></FONT></CENTER></H5>

<BR>

<P>Impatience is another personal trait that increases with the level of authority and responsibility in an organization. Operatives in the trenches might be satisfied with an application that takes a minute or more to present a screen of data, because a 3270 terminal on an overtaxed mainframe might take several minutes to update a session. If your summary queries (especially crosstab queries) need to traverse tens of thousands of records containing line items for a year's collection of invoices, you're certain to face an unsatisfied client when you deliver your production front end.

<BR>

<P>The traditional (and still the best) approach to maintaining adequate performance for time-series decision-support applications is to consolidate time-based detail data into new tables. This process is called <I>rolling up data,</I> a process that should be familiar to all mainframe COBOL programmers. Consolidating data, other than creating monthly and yearly rollups for accounting purposes, has been relatively uncommon in PC-based database applications. High-speed 66 to 100 MHz Intel 80486 and Pentium PCs now have become the most popular CPUs for database servers, and the cost of fixed disk storage has broken the $.20-per-megabyte barrier (no, that's not a misprint&#151;20 cents a megabyte, and by the first quarter of 1996, it might be even lower!). Thus, the economic disincentive of replicating data is minimal.

<BR>

<P>Although rolling up data violates the no-duplicated-data rule for relational databases (because rolled up data is derived from existing tables), you'll probably want to aggregate data when your summary queries need to process more than a few thousand records. Here are some guidelines for how and when to roll up data:

<BR>

<UL>

<LI>Avoid cascading rollups when possible. A <I>cascading rollup</I> is a rollup operation that summarizes data that has been rolled up at a greater detail level. If a retroactive change to the underlying detail occurs, you need to re-aggregate each level in the process.

<BR>

<BR>

<LI>Roll up data at intervals that are likely to be the least subject to retroactive changes. An example is three-month rollups for corporations whose quarterly financial reports are subject to independent audit. Monthly rollups may be necessary to achieve acceptable application performance, but monthly rollups shouldn't be cascaded into quarterly aggregations because retroactive changes may be made in the underlying operational databases. Quarterly rollups are based on records in the operational databases.

<BR>

<BR>

<LI>Never roll up data at the operational-database record level. An example of rolling up data at the operational level is the Order Amount field of the Orders table of the Northwind Traders database. The value in the Order Amount field is the sum of the product of the Order Quantity and Unit Price fields of the line item records in the Order Details table for a single order. Changes that occur in the Order Details table, including partial shipments, must be immediately rolled into records in the Orders table to maintain data consistency. Rollups should be executed on a real-time basis.

<BR>

<BR>

<LI>Roll up data during periods of transaction-processing inactivity, such as nights or weekends. One of the advantages of rolling up data is the elimination of consistency errors that can occur when you aggregate detail information that is being updated simultaneously. You can write a stored procedure that runs unattended on the server to roll up data at predetermined intervals if your application uses Microsoft or Sybase SQL Server or another client-server RDBMS that supports stored procedures.

<BR>

<BR>

</UL>

<P>In the typical information-system hierarchy illustrated in Figure 9.1, rollups of sales, manufacturing, purchasing, finance, and human resources operational databases occur at the director level. Another rollup further consolidates data for the vice presidents of marketing, operations, and administration.

<BR>

<P>The performance improvement you can achieve by rolling up data lets you design Visual C++ decision-support applications that replace slide shows created with Microsoft PowerPoint or similar Windows presentation applications. Using a presentation application to export and re-create graphs and tables in the form of slides is an inefficient, time-consuming process. Many firms now prepare monthly or weekly presentations by transferring summary data to presentation slides. A well-designed Visual C++ decision-support application can return its development cost many times by eliminating the data import and conversion steps. Your Visual C++ presentation application needs to be totally bulletproof, and you'll probably want to store the rolled up data on a local fixed disk to avoid the embarrassment that accompanies the appearance of blank screens or messages that read Unable to connect to server during the presentation.

<BR>

<BR>

<A NAME="E69E163"></A>

⌨️ 快捷键说明

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