我用VC做了一个应用程序,应用程序做好了,现在要用到数据库的东西,不知道怎么加,我建了crecordset和Crecordview类,后运行报了很多错?能告诉我什么原因吗?

解决方案 »

  1.   

    网上例子很多,去www.vckbase.com上找找
      

  2.   

    http://www.csdn.net/Develop/Read_Article.asp?Id=16163
    http://www.vckbase.com/document/listdoc.asp?mclsid=11&sclsid=1105
      

  3.   

    --------------------Configuration: aa - Win32 Debug--------------------
    Compiling resources...
    Compiling...
    StdAfx.cpp
    Compiling...
    aa.cpp
    MainFrm.cpp
    aaDoc.cpp
    aaView.cpp
    recordset.cpp
    e:\仿真程序\aa\recordset.h(14) : error C2504: 'CRecordset' : base class undefined
    e:\仿真程序\aa\recordset.h(16) : error C2629: unexpected 'class recordset ('
    e:\仿真程序\aa\recordset.h(16) : error C2238: unexpected token(s) preceding ';'
    e:\仿真程序\aa\recordset.h(32) : error C2061: syntax error : identifier 'CFieldExchange'
    E:\仿真程序\aa\recordset.cpp(17) : error C2653: 'CRecordset' : is not a class or namespace name
    E:\仿真程序\aa\recordset.cpp(17) : error C2065: 'classCRecordset' : undeclared identifier
    E:\仿真程序\aa\recordset.cpp(19) : error C2065: 'CDatabase' : undeclared identifier
    E:\仿真程序\aa\recordset.cpp(19) : error C2065: 'pdb' : undeclared identifier
    E:\仿真程序\aa\recordset.cpp(20) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
    E:\仿真程序\aa\recordset.cpp(20) : error C2143: syntax error : missing ';' before ':'
    E:\仿真程序\aa\recordset.cpp(21) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
    E:\仿真程序\aa\recordset.cpp(40) : error C2065: 'CFieldExchange' : undeclared identifier
    E:\仿真程序\aa\recordset.cpp(40) : error C2065: 'pFX' : undeclared identifier
    E:\仿真程序\aa\recordset.cpp(41) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
    E:\仿真程序\aa\recordset.cpp(55) : error C2653: 'CRecordset' : is not a class or namespace name
    E:\仿真程序\aa\recordset.cpp(60) : error C2653: 'CRecordset' : is not a class or namespace name
    recordsetview.cpp
    e:\仿真程序\aa\recordset.h(14) : error C2504: 'CRecordset' : base class undefined
    e:\仿真程序\aa\recordset.h(16) : error C2629: unexpected 'class recordset ('
    e:\仿真程序\aa\recordset.h(16) : error C2238: unexpected token(s) preceding ';'
    e:\仿真程序\aa\recordset.h(32) : error C2061: syntax error : identifier 'CFieldExchange'
    e:\仿真程序\aa\recordsetview.h(16) : error C2504: 'CRecordView' : base class undefined
    e:\仿真程序\aa\recordsetview.h(41) : error C2143: syntax error : missing ';' before '*'
    e:\仿真程序\aa\recordsetview.h(41) : error C2433: 'CRecordset' : 'virtual' not permitted on data declarations
    e:\仿真程序\aa\recordsetview.h(41) : error C2501: 'CRecordset' : missing storage-class or type specifiers
    e:\仿真程序\aa\recordsetview.h(41) : error C2501: 'OnGetRecordset' : missing storage-class or type specifiers
    E:\仿真程序\aa\recordsetview.cpp(17) : error C2440: 'return' : cannot convert from 'class recordsetview *' to 'class CObject *'
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    E:\仿真程序\aa\recordsetview.cpp(17) : error C2653: 'CRecordView' : is not a class or namespace name
    E:\仿真程序\aa\recordsetview.cpp(17) : error C2065: 'classCRecordView' : undeclared identifier
    E:\仿真程序\aa\recordsetview.cpp(21) : error C2614: 'recordsetview' : illegal member initialization: 'CRecordView' is not a base or member
    E:\仿真程序\aa\recordsetview.cpp(35) : error C2653: 'CRecordView' : is not a class or namespace name
    E:\仿真程序\aa\recordsetview.cpp(42) : error C2653: 'CRecordView' : is not a class or namespace name
    E:\仿真程序\aa\recordsetview.cpp(54) : error C2653: 'CRecordView' : is not a class or namespace name
    E:\仿真程序\aa\recordsetview.cpp(59) : error C2653: 'CRecordView' : is not a class or namespace name
    E:\仿真程序\aa\recordsetview.cpp(66) : error C2143: syntax error : missing ';' before '*'
    E:\仿真程序\aa\recordsetview.cpp(66) : error C2501: 'CRecordset' : missing storage-class or type specifiers
    E:\仿真程序\aa\recordsetview.cpp(67) : error C2501: 'OnGetRecordset' : missing storage-class or type specifiers
    E:\仿真程序\aa\recordsetview.cpp(69) : error C2440: 'return' : cannot convert from 'class recordset *' to 'int'
            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    E:\仿真程序\aa\recordsetview.cpp(71) : error C2664: '__thiscall recordset::recordset(const class recordset &)' : cannot convert parameter 1 from 'const int' to 'const class recordset &'
            Reason: cannot convert from 'const int' to 'const class recordset'
            No constructor could take the source type, or constructor overload resolution was ambiguous
    E:\仿真程序\aa\recordsetview.cpp(72) : error C2039: 'Open' : is not a member of 'recordset'
            e:\仿真程序\aa\recordset.h(13) : see declaration of 'recordset'
    E:\仿真程序\aa\recordsetview.cpp(74) : error C2440: 'return' : cannot convert from 'class recordset *' to 'int'
            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    E:\仿真程序\aa\recordsetview.cpp(80) : error C2039: 'IsKindOf' : is not a member of 'recordset'
            e:\仿真程序\aa\recordset.h(13) : see declaration of 'recordset'
    E:\仿真程序\aa\recordsetview.cpp(86) : error C2065: 'BeginWaitCursor' : undeclared identifier
    E:\仿真程序\aa\recordsetview.cpp(88) : error C2653: 'CRecordView' : is not a class or namespace name
    E:\仿真程序\aa\recordsetview.cpp(89) : error C2039: 'IsOpen' : is not a member of 'recordset'
            e:\仿真程序\aa\recordset.h(13) : see declaration of 'recordset'
    E:\仿真程序\aa\recordsetview.cpp(91) : error C2039: 'm_pDatabase' : is not a member of 'recordset'
            e:\仿真程序\aa\recordset.h(13) : see declaration of 'recordset'
    E:\仿真程序\aa\recordsetview.cpp(91) : error C2227: left of '->GetDatabaseName' must point to class/struct/union
    E:\仿真程序\aa\recordsetview.cpp(92) : error C2039: 'GetTableName' : is not a member of 'recordset'
            e:\仿真程序\aa\recordset.h(13) : see declaration of 'recordset'
    E:\仿真程序\aa\recordsetview.cpp(95) : error C2065: 'GetDocument' : undeclared identifier
    E:\仿真程序\aa\recordsetview.cpp(95) : error C2227: left of '->SetTitle' must point to class/struct/union
    E:\仿真程序\aa\recordsetview.cpp(97) : error C2065: 'EndWaitCursor' : undeclared identifier
    Generating Code...
    Error executing cl.exe.aa.exe - 50 error(s), 0 warning(s)
      

  4.   

    大家能帮我看看是什么原因吗?我就建了个单文档的工程,然后加了Crecordset和Crecordview两个基类,以编译就出现上面的这么多错?
      

  5.   

    在stdafx.h 中 :加#include <afxdb.h>
      

  6.   

    另外,Crecordset是需要重载很多东西才能用的
      

  7.   

    是不是没在“stdafx.h”中包含#include "afxdb.h"
      

  8.   

    没有包含头文件。
    为什么不用ADO?
      

  9.   

    同意楼上
    ado 会比较好用
      

  10.   

    ado 怎么用呀?我是新手不怎么懂,楼上能说清楚一点吗?