求救:怎样使用Ado Data Control 6.0控件连接Oracle数据库!

bombers 2005-05-29 02:19:51
各位高人请指点小弟,花了快两天时间了,一筹莫展啊!急切企盼高人指点迷经。
本人要开发一个数据库管理工具,功能并不复杂,就是可实现在唯一的管理员身份登录,然后可以进行对数据库中用户的添、删操作及对用户下数据表的修改及数据的修改。
1、工程是SDI的,基于FormView,添加了Ado Data Control 6.0和DataGrid Control 6.0两个控件,想通过Adodc控制连接数据库,并可使用datagrid动态显示不同用户下的不同数据表。
2、现在遇到的一个问题是,我想在工程本身(DBM.cpp)初始化时,显示一个身份验证登录窗口,那是不是要在CDBMApp::InitInstance()中调用窗口,并且是不是要在调用窗口前连接数据库,我是这样作的,虽然编译通过,但一run就报错。我把程序贴在下面:
BOOL CDBMApp::InitInstance()
{
AfxEnableControlContainer();

#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

SetRegistryKey(_T("Local AppWizard-Generated Applications"));

LoadStdProfileSettings(); // Load standard INI file options (including MRU)

m_af.Start("IDR_MATINURF_GTBASE",WINDOW_TYPE_VC,NULL,GTP_LOAD_RESOURCE,NULL,"MATINURF") ;
//这以下是连接数据库,调用登录窗口
CString sLoingstr;
sLoingstr="Provider=MSDASQL.1;Persist Security Info=False;User ID=cg;Data Source=cg";
pAdodc->SetConnectionString(sLoingstr);
pAdodc->SetUserName(_T("cg"));
pAdodc->SetPassword(_T("cg"));
AfxMessageBox(sLoingstr,NULL,MB_OK);
if(dlglogin.DoModal()!=IDOK)
return FALSE;
// 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(CDBMDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CDBMView));
AddDocTemplate(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_SHOW);
m_pMainWnd->UpdateWindow();

return TRUE;
}
经追踪错误信息:提示是由pAdodc->SetConnectionString(sLoingstr);引起的,可实在是不知道什么原因。pAdodc是我在adodc.cpp中添加的指针,在DBM.cpp中extern引用的,这会不会用影响呢?另外,我把adodc控件是放在了登录的对话框中(IDD_LOGINDLG)中,没有设置任何属性。

3、我想在登录对话框(IDD_LOGINDLG)中,验证用户填写的用户名和密码信息是否与工程初始化连接数据库时的信息一致,如果一致pass,否则就提示并退出。那我是不是得在对话框程序中使用GetUserName和GetPassword得到初始化时的信息,然后将它们与用户从Edit框中输入的信息进行对比呢?如何实现呢?请高手们帮帮我,小弟刚学VC两月不到,实在是菜啊。
如能得到满意回答,小弟将倾其所有分数。
...全文
61 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧