| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 505 人关注过本帖
标题:关于C++中编程问题:将链接oracle改为链接access
取消只看楼主 加入收藏
maomao891205
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-5-9
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
关于C++中编程问题:将链接oracle改为链接access
麻烦各位大神们帮忙改一代码:
这是一个叫做KMS的知识库应用(之前一个学长自己编写做的),他的知识库用的是和oracle连接的,我的毕业设计题目和他基本完全一样,就是需要把oracle数据库换成access数据库。但是我自己本身不是学软件或者计算机的(本专业是机械。。。),所以真心不会c++...在书上网上查看了很多,链接数据库都是有标准的这样的模块的,但是这个变成和那些出入很大。。。就无从下手了,还麻烦大家帮忙看看,原来他的代码如下(这是连接oracle的):

// KMS.cpp : Defines the class behaviors for the application.
//
 
#include "stdafx.h"
#include "KMS.h"
 
#include "MainFrm.h"
#include "KMSDoc.h"
#include "KMSView.h"
#include "WelcomeDlg.h"
 
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
 
long m_lLastKnowledgeTextID;
/////////////////////////////////////////////////////////////////////////////
// CKMSApp
 
BEGIN_MESSAGE_MAP(CKMSApp, CWinApp)
         //{{AFX_MSG_MAP(CKMSApp)
         ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
         ON_COMMAND(ID_FILE_NEW, OnFileNew)
         //}}AFX_MSG_MAP
         // Standard file based document commands
         ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
         ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
         // Standard print setup command
         ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
 
/////////////////////////////////////////////////////////////////////////////
// CKMSApp construction
 
CKMSApp::CKMSApp()
{
         // TODO: add construction code here,
         // Place all significant initialization in InitInstance
         m_pDocTemplate = NULL;
         m_lLastKnowledgeTextID = -1;  // 初始化上一次被操作的知识文件的ID号为-1
         GetDefaultConnect();  // 得到程序初始构造时的File dsn的目录
}
 
/////////////////////////////////////////////////////////////////////////////
// The one and only CKMSApp object
 
CKMSApp theApp;
CString FileName = getenv("TEMP");
/////////////////////////////////////////////////////////////////////////////
// CKMSApp initialization
 
BOOL CKMSApp::InitInstance()
{
         AfxOleInit();
         // Initialize OLE libraries
         if (!AfxOleInit())
         {
                   AfxMessageBox(IDP_OLE_INIT_FAILED);
                   return FALSE;
         }
 
         AfxEnableControlContainer();
         // Standard initialization
         // If you are not using these features and wish to reduce the size
         //  of your final executable, you should remove from the following
         //  the specific initialization routines you do not need.
 
#ifdef _AFXDLL
         Enable3dControls();                            // Call this when using MFC in a shared DLL
#else
         Enable3dControlsStatic();        // Call this when linking to MFC statically
#endif
 
         // Change the registry key under which our settings are stored.
         // TODO: You should modify this string to be something appropriate
         // such as the name of your company or organization.
         SetRegistryKey(_T("Local AppWizard-Generated Applications"));
 
         LoadStdProfileSettings(0);  // Load standard INI file options (including MRU)
 
         // Register the application's document templates.  Document templates
         //  serve as the connection between documents, frame windows and views.
 
         CSingleDocTemplate* pDocTemplate;
         pDocTemplate = new CSingleDocTemplate(
                   IDR_MAINFRAME,
                   RUNTIME_CLASS(CKMSDoc),
                   RUNTIME_CLASS(CMainFrame),       // main SDI frame window
                   RUNTIME_CLASS(CKMSView));
         pDocTemplate->SetContainerInfo(IDR_CNTR_INPLACE);
         AddDocTemplate(pDocTemplate);
         m_pDocTemplate = pDocTemplate;
 
         // Parse command line for standard shell commands, DDE, file open
         CCommandLineInfo cmdInfo;
         ParseCommandLine(cmdInfo);
 
         // Dispatch commands specified on the command line
         if (!ProcessShellCommand(cmdInfo))
                   return FALSE;
 
         // The one and only window has been initialized, so show and update it.
         m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
         m_pMainWnd->UpdateWindow();
 
         ConnectRecordsets();  //打开数据库中的记录
 
         return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
 
class CAboutDlg : public CDialog
{
public:
         CAboutDlg();
 
// Dialog Data
         //{{AFX_DATA(CAboutDlg)
         enum { IDD = IDD_ABOUTBOX };
         CAnimateCtrl  m_animate;
         //}}AFX_DATA
 
         // ClassWizard generated virtual function overrides
         //{{AFX_VIRTUAL(CAboutDlg)
         protected:
         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
         //}}AFX_VIRTUAL
 
// Implementation
protected:
         //{{AFX_MSG(CAboutDlg)
         virtual BOOL OnInitDialog();
         //}}AFX_MSG
         DECLARE_MESSAGE_MAP()
};
 
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
         //{{AFX_DATA_INIT(CAboutDlg)
         //}}AFX_DATA_INIT
}
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
         CDialog::DoDataExchange(pDX);
         //{{AFX_DATA_MAP(CAboutDlg)
         DDX_Control(pDX, IDC_ANIMATE_MOUSE, m_animate);
         //}}AFX_DATA_MAP
}
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
         //{{AFX_MSG_MAP(CAboutDlg)
         //}}AFX_MSG_MAP
END_MESSAGE_MAP()
 
// App command to run the dialog
void CKMSApp::OnAppAbout()
{
         CAboutDlg aboutDlg;
         aboutDlg.DoModal();
}
 
/////////////////////////////////////////////////////////////////////////////
// CKMSApp message handlers
void CKMSApp::OnFileNew()
{
         // TODO: Add your command handler code here
         CWinApp::OnFileNew();
}
 
 
void CKMSApp::GetDefaultConnect()
{
         char* buffer = new char[40];
         ::GetCurrentDirectory(40, buffer);
         m_strCurrentDirectory = buffer;
         m_strDefaultConnect += m_strCurrentDirectory;
 
//      m_strDefaultConnect+="\\FileSource.dsn";//m_strDefaultConnect;
 //   AfxMessageBox(m_strDefaultConnect);
//      m_strDefaultConnect="ODBC;FILEDSN="+m_strDefaultConnect+";UID=KMS;PWD=KMS;";
    m_strDefaultConnect = "ODBC;DSN=KMS;UID=KMS;PWD=KMS;";
 
    delete []buffer;
}
void CKMSApp::ConnectRecordsets()
{
         CWelcomeDlg welDlg;
         welDlg.Create(IDD_WELCOME_DLG, NULL);
         CRect rect;
         theApp.m_pMainWnd->GetClientRect(&rect);
        
         welDlg.MoveWindow(rect.right/2 - 150,rect.bottom/2 - 30 , 300, 60, TRUE);
         SetDlgItemText(welDlg.GetSafeHwnd(), IDC_TEXT, "正在检查数据库是否连通,请稍后...");
         welDlg.ShowWindow(SW_SHOW);
 
         CDatabase db;
         m_ptreeRecordSet = new CTreeRecordSet;
         m_pknowledgeRecordSet = new CKnowledgeRecordSet;
         m_pkTextRecordSet = new CKTextRecordSet;
 
         try
         {
                   m_ptreeRecordSet->Open(CRecordset::snapshot, "select * from KNOWLEDGE_TREE", CRecordset::none);
                   m_pknowledgeRecordSet->Open(CRecordset::snapshot, "select * from KNOWLEDGE", CRecordset::none);
                   m_pkTextRecordSet->Open(CRecordset::snapshot, "select * from KNOWLEDGE_TEXT", CRecordset::none);                              
 
                   db.Open(NULL, FALSE, FALSE, _T(((CKMSApp*)AfxGetApp())->m_strDefaultConnect), FALSE); //如果未连通数据库
                  
         }
         catch(CDBException* e)
         {
                   e->Delete();
         }
         if (!db.IsOpen())
         {
                   welDlg.DestroyWindow();
                   AfxMessageBox("数据库未连通,请检查网络是否连接");
                   return;
         }
         db.Close();
 
         welDlg.DestroyWindow();
}
 
 
 
BOOL CAboutDlg::OnInitDialog()
{
         CDialog::OnInitDialog();
        
         // TODO: Add extra initialization here
         m_animate.Open(IDR_MOUSE_AVI);
 
         return TRUE;  // return TRUE unless you set the focus to a control
                       // EXCEPTION: OCX Property Pages should return FALSE
}
搜索更多相关主题的帖子: oracle access 计算机 数据库 学软件 
2013-05-09 15:44
maomao891205
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-5-9
收藏
得分:0 
回复 4楼 rjsp
还是不行,说“is not a member of “CKMSAPP””
2013-05-15 14:16
maomao891205
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-5-9
收藏
得分:0 
回复 6楼 rjsp
恩。。。明白。。。谢谢了。。。
时间太紧来不及好好学。。。学的是机械。。老师让我毕设做软件开发。。。蛋疼
2013-05-20 11:58
快速回复:关于C++中编程问题:将链接oracle改为链接access
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018307 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved