rt
用ADO连接Oracle数据库,进行一些基本操作(读取,增加,删除,修改)3q very much!
用ADO连接Oracle数据库,进行一些基本操作(读取,增加,删除,修改)3q very much!
解决方案 »
- MFC中Ontimer定时器-在程序中这样调用定时器是否会出问题-高手进
- ExitThread强制线程终止运行有什么坏处?
- 关于vs2005 c++中的窗口问题
- select *from table呢,还是select*from table where (...)and (...)...好呢
- ADO 大量数据出问题
- 如何解析这种字符串?
- make文件?
- 有个程序只许运行一个实例,我想运行多个怎么做?
- opencv cvMatchTemplate报错
- MFC编译报错:error BK1506 : cannot open file '.\Debug\StdAfx.sbr': No such ile or dir
- 紧急救助!如何根据文件的路径,打开一个文件?
- 菜鸟请教关于CSocket的问题
{
::CoInitialize(NULL); //初始化OLE/COM库环境
m_pConnection.CreateInstance(_uuidof(Connection)); //初始化Connection指针
m_pRecordset.CreateInstance(_uuidof(Recordset));//初始化Recordset指针 try
{
m_pConnection->Open("Data source = myoraclelink; uid=system; pwd=system;","","",adModeUnknown); //连接叫作ADOTest的ODBC数据源
CString strSql="select * from student";
BSTR bstrSQL = strSql.AllocSysString();
m_pRecordset->Open(bstrSQL,(IDispatch*)m_pConnection,adOpenDynamic,adLockOptimistic,adCmdText);
m_pRecordset->AddNew();///添加新记录
m_pRecordset->PutCollect("sno",_variant_t("9"));
m_pRecordset->PutCollect("name",_variant_t("叶利钦"));
m_pRecordset->Update();
m_pRecordset->Close();
MessageBox("add ok");
}
catch (_com_error e)//异常处理
{
AfxMessageBox(e.ErrorMessage());
}
}void CDataOperDlg::OnDelete()
{
::CoInitialize(NULL); //初始化OLE/COM库环境
m_pConnection.CreateInstance(_uuidof(Connection)); //初始化Connection指针
m_pRecordset.CreateInstance(_uuidof(Recordset));//初始化Recordset指针 try
{
m_pConnection->Open("Data source = myoraclelink; uid=system; pwd=system;","","",adModeUnknown); //连接叫作ADOTest的ODBC数据源
CString strSql="select * from student where sno=9";
BSTR bstrSQL = strSql.AllocSysString();
m_pRecordset->Open(bstrSQL,(IDispatch*)m_pConnection,adOpenDynamic,adLockOptimistic,adCmdText);
m_pRecordset->Delete(adAffectCurrent);
m_pRecordset->Update();
m_pRecordset->Close();
m_pConnection->Close();
MessageBox("del ok");
}
catch (_com_error e)//异常处理
{
AfxMessageBox(e.ErrorMessage());
}}void CDataOperDlg::OnModify()
{
::CoInitialize(NULL); //初始化OLE/COM库环境
m_pConnection.CreateInstance(_uuidof(Connection)); //初始化Connection指针
m_pRecordset.CreateInstance(_uuidof(Recordset));//初始化Recordset指针 try
{
m_pConnection->Open("Data source = myoraclelink; uid=system; pwd=system;","","",adModeUnknown); //连接叫作ADOTest的ODBC数据源
CString strSql="select * from student where sno=1";
BSTR bstrSQL = strSql.AllocSysString();
m_pRecordset->Open(bstrSQL,(IDispatch*)m_pConnection,adOpenStatic,adLockOptimistic,adCmdText);
m_pRecordset->PutCollect("name",_variant_t("voljin"));
m_pRecordset->Update();
m_pRecordset->Close();
m_pConnection->Close();
MessageBox("mod ok");
}
catch (_com_error e)//异常处理
{
AfxMessageBox(e.ErrorMessage());
}
}