各位大哥:
关于 ADO访问数据库 是
编译没有错误,执行时报错 "数据库连接失败!!"
m_pConnection.CreateInstance("ADODB.Connection");
这句跳到了 异常 请问时扫描问题呀 ?????? 我 都搞了半天了,多谢各位帮忙!!!!
关于 ADO访问数据库 是
编译没有错误,执行时报错 "数据库连接失败!!"
m_pConnection.CreateInstance("ADODB.Connection");
这句跳到了 异常 请问时扫描问题呀 ?????? 我 都搞了半天了,多谢各位帮忙!!!!
/*****************************************************
功能:初始化视图,并连接数据源及将记录集与数据源连接在一
起.
历史纪录:andy-21/5/2002
******************************************************/
void CMyView::OnInitialUpdate()
{
CListView::OnInitialUpdate(); CListCtrl& ctrlList = (CListCtrl&) GetListCtrl();
// Gain a reference to the list control itself
ctrlList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_pDatabase=new CDaoDatabase;//初始化数据源指针
try//异常
{
m_pDatabase->Open("library.mdb");//打开数据源
m_pRecordset=new CDaoRecordset(m_pDatabase);
m_pRecordset1=new CDaoRecordset(m_pDatabase);
//打开数据源相关的记录集
}
catch(CDaoException* e)
{
e->ReportError();
delete m_pDatabase;
m_pDatabase=NULL;
e->Delete();
return;
}
CString strKeyEntry;
///////////////////////////////////////////////////////
//从注册表中读出
strKeyEntry=_T("maxday");
m_maxday=AfxGetApp()->GetProfileInt( RegisteKeys, strKeyEntry,21 );
strKeyEntry=_T("maxbook");
m_maxbook=AfxGetApp()->GetProfileInt( RegisteKeys,strKeyEntry,3 );
strKeyEntry=_T("money");
CString money;
money=AfxGetApp()->GetProfileString( RegisteKeys, strKeyEntry,"0.2");
char *temp=money.GetBuffer(money.GetLength()+1);
m_money=atof(temp); ///////////////////////////////////////////////////////
// TODO: You may populate your ListView with items by directly accessing
// its list control through a call to GetListCtrl().
}