关于ado 请指教。。。

bulehawk 2000-09-04 05:23:00
我再用ado编程时遇到一个问题:不能打开代密码的数据库(不用odbc数据源);
代码如下:
hr=m_pConnection->Open(_bstr_t("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=my.mdb"),
_bstr_t(strUserID),_bstr_t("123"),lOptions);
...全文
219 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
seesi 2001-06-05
  • 打赏
  • 举报
回复
连接字符串里写密码的
enterzhuang 2001-06-04
  • 打赏
  • 举报
回复
关注!
netskiff 2001-05-25
  • 打赏
  • 举报
回复
关注!
flyhigh 2001-01-12
  • 打赏
  • 举报
回复
看我的:
m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source =d:\\database\\testdb.mdb;Jet OLEDB:Database Password =hjx","", "", -1);
给分吧,我要断炊了。
halbert 2000-11-22
  • 打赏
  • 举报
回复
关于vc++ 的ado 编程
atdafx.h
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename ("EOF", "adoEOF")

BOOL CGetemailApp::InitInstance()
{
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox("ole 出错");
return FALSE;
}
::CoInitialize( NULL );
}
int CGetemailApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
::CoUninitialize();
return CWinApp::ExitInstance();
}

bool getrecordset()
{
char SqlStr[255],account[50];
char Error[500];
char putfilestr[300];
long recordnum;
m_pConnection = NULL;
m_pRecordset = NULL;
_variant_t TheEmail,ThePhone_office,TheAccount,TheUser_id;
char strEmail[50],strPhone_offiece[50],strAccount[50],strUser_id[50];
if(!OpenFileForReadWrite())
return ;
try{
m_pConnection.CreateInstance(__uuidof(Connection));
m_pRecordset.CreateInstance(__uuidof(Recordset));
recordnum=m_pConnection->Open("DSN=stat","test","test",-1);
sprintf(putfilestr,"%20s %30s %40s %30s\n","用户编码","用户帐号","用户Email","用户办公电话");
fwrite(putfilestr,strlen(putfilestr),1,fpout);
while(!feof(fpin))
{
fscanf(fpin,"%s",account);
sprintf(SqlStr,"select a.user_id,a.account, b.email,b.phone_office from userbasicinfo a,usercontactinfo b where a.account='%s' and b.user_id=a.user_id",account);
recordnum=m_pRecordset->Open(SqlStr,m_pConnection.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
//用 recordnum=m_pRecordset->Open(SqlStr,m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
// 也出错
recordnum=m_pRecordset->adoEOF;
//执行到此出错,为何。跳到catch(...)
if(!m_pRecordset->adoEOF)
{
TheUser_id=m_pRecordset->GetCollect("user_id");

TheAccount=m_pRecordset->GetCollect("account");
TheEmail=m_pRecordset->GetCollect("email");
ThePhone_office=m_pRecordset->GetCollect("phone_office");
sprintf(putfilestr,"%20s %30s %40s %30s\n",TheUser_id.bstrVal,TheAccount.bstrVal,TheEmail.bstrVal,ThePhone_office.bstrVal);
fwrite(putfilestr,strlen(putfilestr),1,fpout);
}//end if
m_pRecordset->Close();
}//end while
}//end try
catch(_com_error *e)
{

//CString Error = e->ErrorMessage();
//char Error[500];
strcpy(Error , (char*)e->Description());
AfxMessageBox(e->ErrorMessage());
}
catch(_com_error e)
{

//CString Error = e->ErrorMessage();
strcpy(Error , (char*)e.Description());
//AfxMessageBox(e->ErrorMessage());
AfxMessageBox(Error);
}
catch(...)
{
AfxMessageBox("ado 出错");
}

m_pRecordset->close();;
m_pConnection->Close();
m_pConnection->Release();
CloseAllFile();
}
// 执行到recordnum=m_pRecordset->adoEOF; 出错 为何
// 请那位大侠指点

ggggwwww 2000-09-06
  • 打赏
  • 举报
回复
it is very easy
http://www.microsoft//data//
download example.
bulehawk 2000-09-06
  • 打赏
  • 举报
回复
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=my.mdb ;password=123;
??
我试过不行啊倾详细一点
celxta 2000-09-04
  • 打赏
  • 举报
回复
密码应加在此句之后:Provider=Microsoft.Jet.OLEDB.4.0;Data Source=my.mdb

16,467

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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