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

📄 vcgfm.htm

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

<BR>

<P><I>This book is dedicated to Kathareeya &quot;Katie&quot; Tonyai, a brand new </I><I>granddaughter.  &#151;Peter Hipson</I>

<BR>

<P><I>This book is dedicated to the memory of my father, George H. Jennings, </I><I>Structural Engineer.  &#151;Roger Jennings</I>

<BR>

<BR>

<A NAME="E68E2"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Copyright &#169; 1996 by Sams Publishing</B></FONT></CENTER></H3>

<BR>

<P>SECOND EDITION

<BR>

<P>All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. For information, address Sams Publishing, 201 W. 103rd St., Indianapolis, IN 46290.

<BR>

<P>International Standard Book Number: 0-672-30913-0

<BR>

<P>Library of Congress Catalog Card Number: 95-72921

<BR>

<P>99 - 98 - 97 - 96 ----4 - 3 - 2 - 1

<BR>

<P>Interpretation of the printing code: the rightmost double-digit number is the year of the book's printing; the rightmost single-digit, the number of the book's printing. For example, a printing code of 96-1 shows that the first printing of the book occurred in 1996.

<BR>

<P><I>Composed in AGaramond, Optima, Helvetica, and MCPdigital by Macmillan </I><I>Computer Publishing</I>

<BR>

<P><I>Printed in the United States of America</I>

<BR>

<P>All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.

<BR>

<BR>

<A NAME="E68E3"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Acknowledgments</B></FONT></CENTER></H3>

<BR>

<P>The authors are indebted to Neil Black of Microsoft's Jet Program Management Group and Stephen Hecht of Microsoft's Jet Development Group for their &quot;Jet Database Engine 2.0 ODBC Connectivity&quot; white paper. This white paper made a substantial contribution to the writing of Chapter 7, &quot;Using the Open Database Connectivity API.&quot; You can find this white paper and a number of other works by these authors on the Microsoft Development Library CD. Search for the authors' names.

<BR>

<P>Special thanks to Microsoft and Steve Serdy at Microsoft Developer Support for their excellent assistance. Steve's help with the Win32 Common Controls was most valuable.

<BR>

<P>Thanks are also due to Robert Bogue and Jeff Perkins, the technical editors for this book. Jeff's help in getting our references to Microsoft SQL Server 6 up-to-date was most valuable. Thanks also to Grace Buechlein, our acquisitions editor. Grace's professionalism was most valuable when we had problems, and we hope to work with her again. Thanks to Michael Watson, our development editor, for his extra work in making sure that the book presented the very latest information available. Thanks also to Gayle Johnson, our production editor, and to Anne Owen, our copy editor.

<BR>

<BR>

<A NAME="E68E4"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>About the Authors</B></FONT></CENTER></H3>

<BR>

<P><B>Peter Hipson</B> is a developer, consultant, and author. His work is mostly in the Windows arena, but he also pursues work in ODBC, database, and GIS applications. He was a member of the Microsoft beta-test team for QuickC for Windows; Visual C++ 1.0, 1.5, 2.0, and 4.0; Windows 3.0 and 3.1; Windows 95; Windows for Workgroups 3.1 and 3.11; and Windows NT. Peter is the author of Sams Publishing's <I>Advanced C, What Every Visual </I><I>C++ 2 Programmer Should Know,</I> and <I>Visual C++ Developer's Guide,</I> as well as Que's <I>Using QuickC for Windows</I>. He was a coauthor of <I>Database </I><I>Developer's Guide with Visual C++</I> and <I>Programming Windows 95 Unleashed,</I> both from Sams Publishing. He also occasionally writes for the <I>Windows </I><I>Technical Journal.</I> He will be writing a column on database programming in <I>The Win'95 Magazine,</I> which will publish its first issue in mid-1996. He also has a column in an Asian magazine on the Internet. Peter has been working with microcomputers since the mid-1970s. He also has many years of experience with IBM mainframes. He is the author of STARmanager, a GIS-type application that assists sales and marketing managers in managing their resources. You may contact Peter via CompuServe (70444,52) or the Internet (<A HREF="mailto:phipson@darkstar.mv.com">phipson@darkstar.mv.com</A>).

<BR>

<P><B>Roger Jennings</B> is a consultant specializing in Windows database, multimedia, and video applications. He was a member of the Microsoft beta-test team for Visual C++ 2.0; Visual Basic 2.0, 3.0, and 4.0; the Professional Extensions for Visual Basic 1.0; Visual Basic for DOS; Microsoft Access 1.0, 1.1, 2.0, and 7; Word for Windows 2.0; the 32-bit versions of Word and Excel; Microsoft Project 4.0 and 4.1; Windows 3.1 and Windows 95; Windows for Workgroups 3.1 and 3.11; Windows NT 3.5, 3.51, and 4.0 Workgroup and Server; the Microsoft ODBC 2.0 and 2.5 drivers; Video for Windows 1.1; and Multimedia Viewer 2.0. Roger is the author of Sams Publishing's <I>Database Developer's Guide with Visual Basic </I><I>4,</I> upon which much of this book is based. He also wrote <I>Access 2 </I><I>Developer's Guide</I> and <I>Access 95 Developer's Guide,</I> both from Sams Publishing, and two other books on Microsoft Access, as well as books devoted to Windows 95, Windows NT, and desktop video production with Windows 95 and Windows NT 3.5x. He also is a contributing editor for Fawcette Technical Publications' <I>Visual Basic Programmer's Journal.</I> Roger has more than 25 years of computer-related experience, beginning with his work on the Wang 700 desktop calculator/computer. He has presented technical papers on computer hardware and software to the Academy of Sciences of the former USSR, the Society of Automotive Engineers, the American Chemical Society, and a wide range of other scientific and technical organizations. He is a principal of OakLeaf Systems, a Northern California software consulting firm. You may contact him via CompuServe (70233,2161), the Internet (<A HREF="mailto:70233.2161@compuserve.com">70233.2161@compuserve.com</A>), or the Microsoft Network (Roger_Jennings).

<BR>

<BR>

<A NAME="E68E5"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Introduction</B></FONT></CENTER></H3>

<BR>

<P>The release of Visual C++ clearly shows that Microsoft is taking the lead in creating C++ development platforms. Visual C++ 4 continues to build on the development platform that the C/C++ program has established. MFC, with versions 2.0, 2.5, 3.0, and 4, offers the C++ programmer an advanced object-oriented methodology to develop applications that are easy to develop and maintain.

<BR>

<P>Microsoft's OLE and the Common Object Model (COM) are now firmly entrenched as the new compound document standard for Windows, and OLE Automation replaces DDE as the primary means of interapplication communication. Huge system resource consumption by OLE megaservers, typified by Excel and Word, limited the adoption of OLE Automation in commercial database front ends. Windows 95 and Windows NT 3.51 have overcome most resource limitations when running 32-bit OLE applications. Thus, 32-bit Visual C++ programs are likely to be the glue that binds industrial-strength solutions orchestrating members of 32-bit Microsoft Office with OLE Automation. Out-of-process OLE Automation servers, especially the big ones, are not renowned for their speed. Fortunately, there's a trend toward a Pentium on every power-user's desktop, so faster hardware comes to the rescue again. OLE Custom Controls (OLE controls), which are in-process OLE Automation servers, don't suffer from the performance hit associated with the Lightweight Remote Procedure Calls (LRPCs) required by out-of-process servers. Thus, OLE controls typically are as quick as VBXs, which OLE controls replace in the 32-bit versions of Windows.

<BR>

<P>Microsoft's addition of the Microsoft Jet database engine's DAO interface to MFC makes Visual C++ a strong competitor to the principal players in the desktop database market: Access, Visual Basic, FoxPro for Windows, Lotus Approach, and Borland International's dBASE and Paradox for Windows. The Open Database Connectivity (ODBC) application programming interface (API), introduced in Visual C++, made Visual C++ a major factor in client-server front-end development throughout the world. DAO promises to lead Visual C++ 4 into areas that in the past have been the private domain of Visual Basic. Using 32-bit ODBC resolves the controversy in the computer press regarding the relative performance of DBLib and ODBC with Microsoft SQL Server. Tests show that 32-bit ODBC is as fast as or faster than equivalent calls to DBLib functions. The three major sections of this Introduction describe the new database connectivity features of Visual C++ and show how Visual C++ fits into the database front-end and back-end market.

<BR>

<BR>

<A NAME="E68E6"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>What's New in Visual C++ for Database Developers</B></FONT></CENTER></H3>

<BR>

<P>Visual C++'s new features of fall into two basic categories:

<BR>

<UL>

<LI>Features that are of interest only to database developers

<BR>

<BR>

<LI>Features that affect all Visual C++ developers, regardless of whether they use Visual C++'s Data Access Objects

<BR>

<BR>

</UL>

<P>First, it is very important to realize that programmers today use many different versions of Visual C++.

<BR>

<UL>

<LI>The first version of Visual C++, 1.0, was available in both a 16-bit and a 32-bit edition. Both of these products are now out-of-date and aren't used much by professional programmers.

<BR>

<BR>

<LI>The next major release of Visual C++, 1.5, was made available only in a 16-bit version. This version included MFC 2.5 and other improvements.

<BR>

<BR>

<LI>The 16-bit versions of Visual C++ that followed Visual C++ 1.5 include 1.51 through 1.52. Version 1.52c is distributed with Visual C++ 4. Microsoft distributes both versions together to give developers of 32-bit applications access to the 16-bit development tools. The 1.5x versions of the 16-bit Visual C++ products incorporate minor changes and additions, such as the inclusion of the OLE controls development platform.

<BR>

<BR>

<LI>The second major release of the 32-bit version of Visual C++ was Visual C++ 2. This product, released in the fall of 1994, supports only 32-bit applications. A redesigned development environment, MFC 3, and other features made Visual C++ 2 a major player in the 32-bit C/C++ development arena.

<BR>

<BR>

<LI>The next release of the 32-bit version of Visual C++ was Visual C++ 4. This product, released in the fall of 1995, supports only 32-bit applications. MFC 4, DAO, numerous improvements to the developer environment, and other features make Visual C++ 4 a must-have for any serious Windows developer.

<BR>

<BR>

<LI>A subscription program was offered to Visual C++ programmers who needed regular updates to Visual C++. Originally slated to be delivered every quarter, releases have been coming out about twice a year. The current subscription program promises the &quot;next two releases,&quot; which would represent about a year in time. Microsoft has announced that Visual C++ 4.1 should be available in the spring of 1996. The subscription version of Visual C++ is available from Microsoft directly and from most resellers.

<BR>

<BR>

</UL>

<P>There will be more releases of Visual C++ as the years go by. However, it is beyond the scope of this book to speculate what the future holds for Visual C++. The following sections describe the categories of Visual C++ features.

<BR>

<BR>

<A NAME="E69E3"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>New Features of Visual C++</B></FONT></CENTER></H4>

<BR>

<P>The most apparent change in Visual C++ 4 for database programmers is the adoption of MFC 4 and the addition of the MFC Data Access Object (DAO) classes. Additionally, Windows 95's Rich Text common control has been integrated into MFC. The following list briefly describes the most important differences between Visual C++ 4 and earlier versions of Visual C++:

<BR>

<UL>

<LI>Visual C++ 1.5x develops 16-bit applications, whereas Visual C++ 4 is a 32-bit (only) development platform.

<BR>

<BR>

<LI>Visual C++ 4 uses a much more advanced development environment. The integration of Visual C++ 4's components is much tighter than it was with Visual C++ 2. There have been major improvements to Visual C++ 4's ClassWizard, too. This lets the programmer have docked windows, more flexible toolbars, and other ease-of-use features.

<BR>

<BR>

<LI>Visual C++ 4 offers MFC 4 and supports 32-bit OLE.

<BR>

<BR>

<LI>Visual C++ 4 has integrated the functionality of the AppStudio program (which is used to edit program resources) into Visual C++'s development environment. There are improved toolbar editing and design tools, and the graphics editor is much better. For programmers who are just moving up to the 32-bit version of Visual C++, there is no need to switch between Visual C++ and AppStudio while developing applications.

<BR>

<BR>

<LI>Visual C++ 4 can edit resources in applications. You can use this functionality, missing from Visual C++ 2, when running Visual C++ 4 under Windows NT.

<BR>

<BR>

<LI>Visual C++ applications support toolbars, status bars, dialog bars, and floating palettes. Toolbars are dockable and have optional tooltip support built-in.

<BR>

<BR>

<LI>Visual C++ supports 32-bit OLE Custom Controls, more commonly called OLE controls in this book. Because VBX controls can't be used in 32-bit environments, OLE controls are your only custom control choice when creating 32-bit Visual C++ 4 applications. Third-party VBX publishers have created a wide array of OLE controls, with functionality similar to their most popular VBX controls.

<BR>

<BR>

<LI>Visual C++ 4 comes with a number of useful OLE controls, including the ever-popular Grid control, and a number of sample controls that can be rewritten if you like.

<BR>

<BR>

<LI>Customization lets you alter Visual C++'s user interface by adding menu choices, modifying toolbars, and manipulating other elements of the design environment. Visual C++ 4 lets you configure the editor to emulate either the Brief or Epsilon editors.

<BR>

<BR>

<LI>Visual C++ 4 supports remote debugging using either a network connection or serial ports. However, there is still no support for dual-monitor debugging.

<BR>

<BR>

<LI>You can create out-of-process OLE miniservers (OLE applets, typified by Microsoft Graph 5.0) that you can use with any application that can act as an OLE Automation client, including Visual C++. Microsoft calls these miniservers <I>LOBjects</I> (line-of-business objects). You can run multiple instances of Visual C++ in order to test your newly created OLE applet.

<BR>

<BR>

</UL>

<BR>

⌨️ 快捷键说明

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