详细说一下两种模式那种好,最好是给点细节性的东西。比如:从数据源连接到访问再到数据永久性等,数据绑定等。谢谢。如有不是很忙的请帮一下,如果那位需要加分就另加。

解决方案 »

  1.   

    ADO,OLEDB技术哪是三言二语能讲完的,找本书才是好的办法。
    ADO的基础是OLEDB技术。比OLEDB更高层,易用。OLEDB是底层技术。
    用VC开发数据库还是推荐用OLEDB。(还是根据你的需要来用)
      

  2.   

    ODBC只能访问关系式数据库。
    OLEDB的基础技术是COM技术。数据来源不一定是关系式数据库。
      

  3.   

    THE DILEMMA OF DATA ACCESS
    When it comes to choosing the right data access technology for application development, most Visual C++ programmers face a puzzling set of choices. On one hand, these choices are limited and on the other hand, they are conflicting in terms of performance requirement and ease of use. Whether it is a stand-alone application, a client/server application or a web application, a C++ programmer would never like to compromise the factors of decision such as performance, speed, and resource management. The simple reason for this fact is the underlying tenet that the C++ programmers are supposed to churn out some smartest applications in the programming world. Although the type and make of the database as well as the nature of application can largely influence the decision, it is not as easy as it seems.Let us try to understand and analyze some of the most obvious data access choices:Native Library :
    Native libraries are supplied by many database vendors and they provide fastest data access for the respective databases. However, due to the well-known fact that the code written using a native library is not portable to other databases, your application gets locked into the database vendor抯 technology. Moreover, each native library is totally different in nature compared to other libraries. So, we will not devout any time discussing this option in detail and leave it to the developers to explore further on this topic.ADO :
    Since its introduction, ADO has been the most widely used option for data access on Windows platform. Though primarily designed and developed for Visual Basic and scripting languages, it is not used less in Visual C++ world either. After ODBC, ADO is the major library that is proven and tested for data access on Windows platform. Thousands of developers using various programming languages on windows platform heavily rely on ADO for the data access need of their applications. Having said that, you might wonder why ADO is not an ideal choice for Visual C++ developers. Well, Here is why:ADO is designed keeping in mind the automation-based languages. So, everything it speaks is in terms of VARIANT, a data type that is hated most by C++ developers. When it comes to using VARIANTs and BSTRs, C++ developers get a hitch. The reason for this disliking is clearly understandable. Converting a VARIANT to and from the native data types of C++ is really a pain. Not only does it call for extra work, but also it affects the overall performance of the application.ADO is a set of wrapper classes that are built on top of OLE DB interfaces. So, it puts an extra layer as far as C++ is concerned since OLE DB interfaces can be directly accessed through C++. Theoretically, an application that uses OLE DB interfaces is considerably faster than the one that uses ADO.Using ADO in Visual C++ also comes with other drawbacks and limitations. If you use #import statement, you cannot avoid jump-to-exception situation even if you want to avoid it. Additionally, you loose flexibility of having default arguments to the methods. You must provide all method arguments.If you use ADO SDK or raw COM interfaces, you have to check for HRESULT values at each and every point. Since data access code normally requires frequent method calls, it becomes cumbersome to check these values.Concluding on all the points mentioned above, we could say that ADO should be the choice of data access for C++ programmers only if there is no better choice than that.OLE DB Consumer Templates :
    To overcome the limitations of using ADO in C++, Microsoft provided OLE DB consumer templates for C++ developers. Like ADO, they are a set of template classes that are also built around OLE DB interfaces. However, unlike ADO, these classes put only a thin layer on OLE DB and therefore they are lighter, faster, and much powerful. Besides, consumer templates make a native C++ class library, i.e., it is a pure C++ class library and hence it uses the native C++ data types. So, using these classes eliminate the need for using VARIANTs or BSTRs.Putting all these facts together, one can easily conclude that OLE DB consumer classes have an edge over ADO. Yes, they definitely have. You might wonder then why in the world would any C++ programmer use ADO at all. Adding to your wonder is the fact that more C++ developers use ADO in their applications than OLE DB consumer templates. But, wait a minute. There are several good reasons for this fact. Let us see. I am going to list a few of these reasons below.Memory leaks & bugs : The OLE DB consumer templates contain several classes with bugs and memory leak problems. Most notable of them are the methods of CDataSource class that leak memory and the column binding in CDynamicAccessor class that does not handle wide characters properly. As of Service Pack 5 of Visual Studio 6.0, these problems are not fixed. Lack of features and flexibility : Although consumer templates are much easier to use than raw OLE DB interfaces, they lack several features and functionalities compared to ADO. Checking EOF/BOF status in a rowset, handling BLOB data, refreshing and updating a rowset, fetching error details from HRESULT values are just a few of them to list. Using a data access library without these features in your application is a big work in itself. Error reporting : Most methods of consumer template classes return some HRESULT value. Getting error details from these values requires a fair amount of effort, especially if you want to get the error messages from database server. There is no easy shortcut in consumer templates to do this. Lack of XML support : There is no XML support so far in the consumer template classes. Looking at the .NET version of Visual C++, it seems like Microsoft is planning to incorporate XML support in .NET consumer templates. But till then, you have to resort to your own knowledge of database and XML if you use consumer templates. Cryptic and sparse documentation : If you have moved from ADO to consumer templates, you would find the documentation of consumer templates suffocating. The documentation provided in MSDN is short and sparse and very limited in terms of providing examples and samples. In addition to all these facts, there is hardly any good book in et on OLE DB consumer classes that provides the complete coverage of all the classes. Binding to controls : Unless you are writing a middleware component or a web application, you need to display your data in some form of GUI components. It could be as simple as a text box or as complex as a compound spreadsheet grid. In any case, you need to bind your data to the user interface at some point of time in your application development cycle. Most commercial controls provide data-binding support for ADO. However, since consumer templates are a low-level interface to data, the binding responsibility is rested upon the developer. And binding data to a control is not as simple as point-and-click. This is the reason why many developers choose to convert their OLE DB rowset data into ADO Recordset object for displaying them in GUI. Steeper learning curve : Using OLE DB consumer templates for such basic tasks as inserting and deleting rows from a database table is not a problem. However, if you want to move little above that level, you need to understand well the nitty-gritty of OLE DB. As for example, if you want to create an updateable client-side cursor, not only a lot of work is needed, but also the firm understanding of OLE DB interfaces is must. The fact remains that no matter what technology you use, if you want to access databases at lower level, there is no easy way. And consumer templates are no exception.
      

  4.   

    ado 就是微软为了其他编程工具(非VC)而把ole db包装了一下产生的东西。
    所以说在vc环境下,只有ole db 才是最好的数据库开发方法。
    不过ole db sdk是一堆com接口,ATL包装成了一堆模板类,所以没有ado好弄.可以这么说:ado根本不是给vc开发数据库用的。
    但是如果你对ATL不熟悉,
    只好将就用ADO了。