本文整理汇总了C++中_ConnectionPtr类的典型用法代码示例。如果您正苦于以下问题:C++ _ConnectionPtr类的具体用法?C++ _ConnectionPtr怎么用?C++ _ConnectionPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了_ConnectionPtr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: OpenDB
DWORD CNHSQLServerDBO::OpenDB(_ConnectionPtr &pConnection,
const wchar_t *const pwchDataSource,
const wchar_t *const pwchInitialCatalog,
const wchar_t *const pwchUserID,
const wchar_t *const pwchPassword)
{
assert(NULL != pwchDataSource);
assert(NULL != pwchInitialCatalog);
assert(NULL != pwchUserID);
assert(NULL != pwchPassword);
DWORD dwReturn(0x00);
wchar_t wchSql[MAX_PATH];
ZeroMemory(wchSql, sizeof(wchSql));
// 加载COM组件
CoInitialize(NULL);
try
{
_snwprintf_s(wchSql, _countof(wchSql), _TRUNCATE, L"Provider=SQLOLEDB; Data Source=%s; Initial Catalog=%s; User ID=%s; Password=%s;",
pwchDataSource,
pwchInitialCatalog,
pwchUserID,
pwchPassword);
pConnection.CreateInstance(L"ADODB.Connection");
//pConnection->ConnectionTimeout = 5;
//pConnection->CommandTimeout = 5;
pConnection->Open((_bstr_t)wchSql, L"", L"", adModeUnknown);
}
catch (_com_error &e)
{
//#ifdef _DEBUG
const int nErrMsgLength(MAX_PATH);
wchar_t *pwchErrMsg = new wchar_t[nErrMsgLength]();
_snwprintf_s(pwchErrMsg, nErrMsgLength, _TRUNCATE, L"CNHSQLServerDBO::OpenDB发生错误(执行%s)。", wchSql);
// 输出错误信息到输出窗口
OutputDebugStringW(L"\t");
OutputDebugStringW(pwchErrMsg);
OutputDebugStringW(L"\n");
// 输出错误信息到日志文件
if (0 != wcscmp(m_wchLogFilePath, L""))
{
// 当日志文件路径不为空时,写日志
CNHLogAPI::WriteLogEx(m_wchLogFilePath, LOG_ERR, L"NHSQLServerDBO", pwchErrMsg);
}
if (NULL != pwchErrMsg)
{
delete[] pwchErrMsg;
pwchErrMsg = NULL;
}
OutputDBErrMsg(e);
//#endif
dwReturn = 0x01;
}
return dwReturn;
}
开发者ID:musclecui,项目名称:Solution1,代码行数:59,代码来源:NHSQLServerDBO.cpp
示例2: ADOConExec
int CCommDBOper::ADOConExec(_ConnectionPtr &pCon,const CString strCmdSql,CString strDcrCmd,int iWarn)
{
//函数功能说明: 由pCon(Connection)对象执行指定SQL命令
//pCon 数据库连接对象
//strCmdSql 要执行SQL的命令语句
//strDcrCmd是对要使用SQL命令的描述
if (ADOConIsOpened(pCon,iWarn) != RET_OK) //判断当前连接对象是否已打开
{
WarnMessage("指定数据库对象未连接,退出!",iWarn);
return RET_FAILED;
}
try
{
pCon->Execute(_bstr_t(strCmdSql),NULL,adCmdText);
}
catch (_com_error &e)
{
CString strMsg;
strMsg.Format("%s:%d %s", __FILE__, __LINE__, (LPSTR)e.Description());
AfxMessageBox(strMsg);
CString errormessage;
errormessage.Format("功能说明: %s\r\n数据库连接对象执行下列SQL命令\r\n%s\r\n失败! 错误信息:%s",strDcrCmd,strCmdSql,e.ErrorMessage());
WarnMessage(errormessage,iWarn);///显示错误信息
return RET_FAILED;
}
return RET_OK;
}
开发者ID:uesoft,项目名称:AutoPHS,代码行数:27,代码来源:CommDBOper.cpp
示例3: GetADOError
///////////////////////////////////////////////////////
//
// Name: GetADOError
// Params: Conn1 - connection pointer
// Returns: ADO error string
// Description: determines ADO error(s) that occurred
///////////////////////////////////////////////////////
std::string GetADOError(_ConnectionPtr Conn1)
{
USES_CONVERSION;
ErrorsPtr Errs1 = NULL;
ErrorPtr Err1 = NULL;
std::string sRet("ADO Error. Description: ");
long nCount;
try
{
if( Conn1 == NULL ) return sRet + (std::string)"NULL Connection";
// Enumerate Errors Collection and display properties of each object.
Errs1 = Conn1->GetErrors();
nCount = Errs1->GetCount();
// Loop through Errors Collection
for( long i = 0; i < nCount; i++ )
{
// Get Error Item
Err1 = Errs1->GetItem((_variant_t)((long)i) );
sRet += (std::string)" Description: " + (std::string)OLE2T(Err1->GetDescription());
}
if( Errs1 != NULL ) Errs1->Release();
if( Err1 != NULL ) Err1->Release();
}
catch(...)
{
sRet += " Unknown Error";
}
return sRet;
}
开发者ID:cice,项目名称:ODBCSocketServer,代码行数:42,代码来源:main-server.cpp
示例4: CloseDB
DWORD CNHSQLServerDBO::CloseDB(_ConnectionPtr &pConnection)
{
//assert(NULL != pConnection);
DWORD dwReturn(0x00);
try
{
//关闭连接
if (NULL!=pConnection && adStateClosed!=pConnection->State)
{
pConnection->Close();
}
if (NULL != pConnection)
{
pConnection.Release();
pConnection = NULL;
}
}
catch (_com_error &e)
{
//#ifdef _DEBUG
// 输出错误信息到输出窗口
OutputDebugStringW(L"\t");
OutputDebugStringW(L"CNHSQLServerDBO::CloseDB发生错误。");
OutputDebugStringW(L"\n");
// 输出错误信息到日志文件
if (0 != wcscmp(m_wchLogFilePath, L""))
{
// 当日志文件路径不为空时,写日志
CNHLogAPI::WriteLogEx(m_wchLogFilePath, LOG_ERR, L"NHSQLServerDBO", L"CNHSQLServerDBO::CloseDB发生错误。");
}
OutputDBErrMsg(e);
//#endif
dwReturn = 0x01;
}
// 卸载COM组件
CoUninitialize();
return dwReturn;
}
开发者ID:musclecui,项目名称:Solution1,代码行数:42,代码来源:NHSQLServerDBO.cpp
示例5: ADOCloseConnectDB
//断开指定数据库连接对象连接
int CCommDBOper::ADOCloseConnectDB(_ConnectionPtr &pCon,int iWarn)
{
if ((pCon != NULL) && (pCon->State == adStateOpen) )
{
try
{
pCon->Close();
}
catch (_com_error &e)
{
CString strMsg;
strMsg.Format("%s:%d %s", __FILE__, __LINE__, (LPSTR)e.Description());
AfxMessageBox(strMsg);
}
}
return RET_OK;
}
开发者ID:uesoft,项目名称:AutoPHS,代码行数:18,代码来源:CommDBOper.cpp
示例6: ExecuteDML
DWORD CNHSQLServerDBO::ExecuteDML(const _ConnectionPtr &pConnection, const wchar_t *const pwchSQL, int *const pnRowsInvolved/*=NULL*/)
{
assert(NULL != pConnection);
assert(NULL != pwchSQL);
DWORD dwReturn(0x00);
try
{
_variant_t vRA;
pConnection->Execute((_bstr_t)pwchSQL, &vRA, adCmdText);
if (NULL != pnRowsInvolved)
{
*pnRowsInvolved = static_cast<int>(vRA);
}
}
catch (_com_error &e)
{
//#ifdef _DEBUG
const int nErrMsgLength(MAX_PATH);
wchar_t *pwchErrMsg = new wchar_t[nErrMsgLength]();
_snwprintf_s(pwchErrMsg, nErrMsgLength, _TRUNCATE, L"CNHSQLServerDBO::ExecuteDML发生错误(执行%s)。", pwchSQL);
// 输出错误信息到输出窗口
OutputDebugStringW(L"\t");
OutputDebugStringW(pwchErrMsg);
OutputDebugStringW(L"\n");
// 输出错误信息到日志文件
if (0 != wcscmp(m_wchLogFilePath, L""))
{
// 当日志文件路径不为空时,写日志
CNHLogAPI::WriteLogEx(m_wchLogFilePath, LOG_ERR, L"NHSQLServerDBO", pwchErrMsg);
}
if (NULL != pwchErrMsg)
{
delete[] pwchErrMsg;
pwchErrMsg = NULL;
}
OutputDBErrMsg(e);
//#endif
dwReturn = 0x01;
}
return dwReturn;
}
开发者ID:musclecui,项目名称:Solution1,代码行数:44,代码来源:NHSQLServerDBO.cpp
示例7: tableExists
BOOL newproject::tableExists(_ConnectionPtr pCon, CString tbn)
{
if(pCon==NULL || tbn=="")
return false;
_RecordsetPtr rs;
if(tbn.Left(1)!="[")
tbn="["+tbn;
if(tbn.Right(1)!="]")
tbn+="]";
try {
rs=pCon->Execute(_bstr_t(tbn),NULL,adCmdTable);
rs->Close();
return true;
}
catch(_com_error e)
{
return false;
}
}
开发者ID:uesoft,项目名称:AutoIPED,代码行数:20,代码来源:newproject.cpp
示例8: ImportExcelToAccess
//------------------------------------------------------------------
// DATE :[2005/09/30]
// Parameter(s) :
// Return :
// Remark :将EXCEL文件导出到ACCESS数据库表中
//------------------------------------------------------------------
BOOL CImportAutoPD::ImportExcelToAccess(CString strExcelFileName, CString strWorksheetName, _ConnectionPtr pConDes, CString strTblName,CString strCurProID,CString KeyFieldName,CString ProFieldName)
{
CString strSQL; //SQL语句
_ConnectionPtr pConExcel; //连接EXCEL文件
_RecordsetPtr pRsExcel;
_RecordsetPtr pRsAccess;
_RecordsetPtr pRsTmp;
pConExcel.CreateInstance(__uuidof(Connection));
pRsExcel.CreateInstance(__uuidof(Recordset));
pRsAccess.CreateInstance(__uuidof(Recordset));
pRsTmp.CreateInstance(__uuidof(Recordset));
STRUCT_ENG_ID listID[10]; //不同工程的最大序号和工程名称
int nProCount=0; //不同工程的个数
CString strTemp;
int Rj=0; //工程号在Excel中的列
int ProjNum=1;
int ProjIndex=0;
int ID;
if (NULL == pConDes)
{
return FALSE;
}
try
{
EDIBgbl::CAPTION2FIELD* pFieldStruct=NULL;
_variant_t varTmp;
//获得EXCEL中的字段名和ACCESS中的字段的对应值,返回字段个数
int nFieldCount = GetField2Caption(pFieldStruct);
if (nFieldCount <= 0)
{
return FALSE;
}
strSQL = CONNECTSTRING_EXCEL + strExcelFileName;//连接EXCEL文件
pConExcel->Open(_bstr_t(strSQL), "", "", -1);
//打开Excel工作表,加一个符号$如果出错再重试不加$再打开一次.
strSQL = "SELECT * FROM ["+strWorksheetName+"$]";
try
{
pRsExcel->Open(_variant_t(strSQL), pConExcel.GetInterfacePtr(), adOpenStatic, adLockOptimistic, adCmdText);
}
catch (_com_error)
{
strSQL = "SELECT * FROM ["+strWorksheetName+"]";
pRsExcel->Open(_variant_t(strSQL), pConExcel.GetInterfacePtr(), adOpenStatic, adLockOptimistic, adCmdText);
}
if (pRsExcel->adoEOF && pRsExcel->BOF)
{
AfxMessageBox("文件中没有记录!");
return FALSE;
}
//打开Access表
strSQL = "SELECT * FROM ["+strTblName+"] WHERE "+ProFieldName+"='"+strCurProID+"' ORDER BY "+KeyFieldName+" ";
pRsAccess->Open(_variant_t(strSQL), pConDes.GetInterfacePtr(), adOpenStatic, adLockOptimistic, adCmdText);
if (pRsAccess->adoEOF && pRsAccess->BOF)
{
ID=0;
}
else
{
pRsAccess->MoveLast();
ID = vtoi(pRsAccess->GetCollect(_variant_t(KeyFieldName)));
}
ID++;
listID[0].ID = ID; //当前工程最大的序号
listID[0].EnginID = strCurProID;
for(;Rj < nFieldCount;Rj++)
{
if( !ProFieldName.CompareNoCase(pFieldStruct[Rj].strField) )
{
break;
}
}
_RecordsetPtr pRsTmp;
pRsTmp.CreateInstance(__uuidof(Recordset));
CString strGroup; //作为关键字的所有字段组合
//strGroup = "[管道外径/规格], [管道壁厚], [管内压力], [介质温度], [管道材质]";
/* strGroup = "[卷册号],[色环],[管道/设备名称],[管道外径/规格],[管道壁厚],[介质温度],[安装地点],[管道材质],[备注],\
[内保温层材料名称],[外保温层材料名称],[保护层材料名称],[风速],[热价比主汽价],[年运行小时数],\
[油管道保温厚],[管内压力],[管内介质],[工程代号]";
strSQL = "SELECT "+strGroup+" FROM ["+strTblName+"] WHERE "+ProFieldName+"="+strCurProID+" ";
pRsTmp->Open(_variant_t(strSQL), pConDes.GetInterfacePtr(), adOpenStatic, adLockOptimistic, adCmdText);
if (pRsTmp->adoEOF && pRsTmp->BOF)
{
variant_t var = pRsTmp->GetCollect(_variant_t("enginid"));
//.........这里部分代码省略.........
开发者ID:uesoft,项目名称:AutoIPED,代码行数:101,代码来源:ImportAutoPD.cpp
示例9: ADOOpenDBCon
int CCommDBOper::ADOOpenDBCon(_ConnectionPtr &pCon,const CString strDB,CString &strPassword,int iWarn)
{
//函数功能 打开指定数据库
//输入参数说明 pCon 要打开的数据库对象,strDB 要连接的ACCESS数据库文件全路径
// strPassword 密码 iWarn 出错警告方式 0,不警告,1,警告,2,警告且退出程序
//作者 LFX
CString strCon;
_TCHAR dbConnectionString[]=_T("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=%s;Jet OLEDB:Database Password=%s");
strCon.Format(dbConnectionString,strDB,strPassword);
if(!PathFileExists(_T(strDB)))
{
WarnMessage("要打开的数据库文件名不存在!!!",iWarn);
return RET_FAILED;
}
if (pCon == NULL)
{
pCon.CreateInstance(__uuidof(Connection) );
}
else
{
ADOCloseConnectDB(pCon,0);
}
int iLoop = 0;
while (true)
{
//连接ACCESS数据库
iLoop++;
//如果没密码,且为第一次循环
if ( strPassword.IsEmpty() && (iLoop <= 1))
{
try
{
pCon->Open(_bstr_t(strCon),"","",-1);
}
catch(_com_error &e)
{
CString strTemp;
CInputBox inputBox;
inputBox.m_bIsProtected = TRUE;
strTemp.LoadString(IDS_NEEDPASSWORD);
inputBox.m_strWndText.Format("%s%s",strDB,strTemp);
inputBox.m_strTitle.LoadString(IDS_PLEASEINPUTDBPASSWORD);
if (inputBox.DoModal() != IDOK)
{
WarnMessage("密码错误,打开数据库失败!!!",iWarn);
return RET_FAILED;
}
else
{
strPassword = inputBox.m_strValue;
}
}
break;
}
//如果有密码
try
{
pCon->Open(_bstr_t(strCon),"","",-1);
}
catch (_com_error &e)
{
CString strMsg;
strMsg.Format("%s:%d %s", __FILE__, __LINE__, (LPSTR)e.Description());
AfxMessageBox(strMsg);
CString errormessage;
errormessage.Format("打开数据库 %s 失败!\r\n错误信息:%s",strDB,e.ErrorMessage());
WarnMessage(errormessage,iWarn);
return RET_FAILED;
}
break;
} //END while(true)
return RET_OK;
}
开发者ID:uesoft,项目名称:AutoPHS,代码行数:76,代码来源:CommDBOper.cpp
示例10: SetConnection
bool RxADO::SetConnection(CString LinkString)
{
::CoInitialize(NULL);
cnn=NULL;
cnn.CreateInstance(__uuidof(Connection));
cnn->ConnectionString=(_bstr_t)LinkString;
try{
cnn->Open(L"",L"",L"",adCmdUnspecified);
}
catch(_com_error& e)
{
ErrorsPtr pErrors=cnn->GetErrors();
if (pErrors->GetCount()==0)
{
CString ErrMsg=e.ErrorMessage();
MessageBox(NULL,"·¢Éú´íÎó:\n\n"+ErrMsg,"ϵͳÌáʾ",MB_OK|MB_ICONEXCLAMATION);
return false;
}
else
{
for (int i=0;i<pErrors->GetCount();i++)
{
_bstr_t desc=pErrors->GetItem((long)i)->GetDescription();
MessageBox(NULL,"·¢Éú´íÎó:\n\n"+desc,"ϵͳÌáʾ",MB_OK|MB_ICONEXCLAMATION);
return false;
}
}
}
return true;
}
开发者ID:ice98,项目名称:mycode_bak,代码行数:30,代码来源:RxADO.cpp
示例11: ConnectData
UINT CSplash::ConnectData(LPVOID ps)
{
AfxOleInit(); //初始化COM库
if(FAILED(HospitalConnect.CreateInstance(__uuidof(Connection))))
{
((CSplash *)ps)->ConnectFlag=true;
((CSplash *)ps)->timer_count=3; //连接COM失败标志
((CSplash *)ps)->SendMessage(WM_CLOSE,0,0);
return 0;
}
try{
HospitalConnect->Open(_bstr_t(theApp.strConn),"","",adModeUnknown);
((CSplash *)ps)->ConnectFlag=true;
((CSplash *)ps)->timer_count=1; //连接成功标志
((CSplash *)ps)->SendMessage(WM_CLOSE,0,0);
return 1;
}
catch(_com_error e)
{
((CSplash *)ps)->ConnectFlag=true; //作为进度条线程停止标志
((CSplash *)ps)->timer_count=2; //连接失败标志
((CSplash *)ps)->SendMessage(WM_CLOSE,0,0);
return 2;
}
}
开发者ID:lingshaoqing,项目名称:Cplusplus-Source-Code,代码行数:35,代码来源:Splash.cpp
示例12: FieldToOtherField
/*
µ±nStale=1ʱ ×Ö·û×ֶηµ»Ø×Ö·û×Ö¶Î
µ±nStale=2ʱ ÊýÖµ×ֶηµ»Ø×Ö·û×Ö¶Î
µ±nStale=3ʱ ÈÕÆÚ×ֶηµ»Ø×Ö·û×Ö¶Î
*/
CString RxADO::FieldToOtherField(CString cDataBaseName, CString cFieldName, CString cValue, CString cReturnField, int nStale=1)
{
CString sSQL,sRTValue;
_RecordsetPtr Fieldrst;
Fieldrst.CreateInstance(__uuidof(Recordset));
Fieldrst.CreateInstance(__uuidof(Recordset));
if(nStale==1) //×Ö·û×ֶηµ»Ø×Ö·û×Ö¶Î
sSQL.Format("SELECT * FROM %s WHERE %s='%s'",cDataBaseName,cFieldName,cValue);
if(nStale==2)//ÊýÖµ×ֶηµ»Ø×Ö·û×Ö¶Î
sSQL.Format("SELECT * FROM %s WHERE %s=%s",cDataBaseName,cFieldName,cValue);
if(nStale==3)//ÈÕÆÚ×ֶηµ»Ø×Ö·û×Ö¶Î
sSQL.Format("SELECT * FROM %s WHERE %s=#%s#",cDataBaseName,cFieldName,cValue);
try{
Fieldrst=cnn->Execute((_bstr_t)sSQL,NULL,adCmdText);
}
catch(_com_error&e)
{
GetADOErrors(e);
return "";
}
if(GetRecordCount(Fieldrst)<=0)
return "";
_variant_t vValue=Fieldrst->GetCollect((_bstr_t)cReturnField);
if(vValue.vt==VT_EMPTY)
return "";
sRTValue=(char*)(_bstr_t)vValue;
sRTValue.TrimRight();
sRTValue.TrimLeft();
return sRTValue;
}
开发者ID:ice98,项目名称:mycode_bak,代码行数:35,代码来源:RxADO.cpp
示例13: GetConnectIP
CString GetConnectIP()
{
CString bstr = (char*)theConnection->GetConnectionString();
int nl = bstr.Find("Data Source=") + strlen("Data Source=");
int nr = bstr.Find(";", nl);
return bstr.Mid(nl, nr-nl);
}
开发者ID:niepp,项目名称:sperm-x,代码行数:7,代码来源:SpermView.cpp
示例14: ExitConnect
//断开连接
void ExitConnect(void)
{
if(m_pRecordset!=NULL){
m_pRecordset->Close();
m_pConnection->Close();
}
::CoUninitialize(); //释放环境
}
开发者ID:mz247,项目名称:C-C-,代码行数:9,代码来源:adoConnectSQL.cpp
示例15: OnInitADOConn
// //封闭ADO类,方便以后使用
void ADOConn::OnInitADOConn(void)
{
::CoInitialize(NULL);
try
{
//创建connection对象
m_pConnection.CreateInstance("ADODB.Connection");
//设置连接字符串
_bstr_t strConnect="uid=;pwd=;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=Grades.mdb;";
//SERVER和UID,PWD的设置根据实际情况来设置"
/*m_pConnection->Open(strConnect,_T("admin"),_T("owenyang"),adModeUnknown);*/
m_pConnection->Open(strConnect,"admin","owenyang",adModeUnknown);
}
catch (_com_error e)
{
//显示错误信息
AfxMessageBox(e.Description());
}
}
开发者ID:owenyang0,项目名称:ADOConn,代码行数:20,代码来源:ADOConn.cpp
示例16: ExitConnect
void ADOConn::ExitConnect(void)
{
//关闭记录集和连接
if (m_pRecordset!=NULL)
{
m_pRecordset->Close();
}
m_pConnection->Close();
::CoUninitialize();
}
开发者ID:owenyang0,项目名称:ADOConn,代码行数:11,代码来源:ADOConn.cpp
示例17: Connect
//连接SQL
void Connect()
{
try{
::CoInitialize(NULL); //初始化COM环境
m_pConnection.CreateInstance(__uuidof(Connection)); //创建连接对象
//通过DSN数据源对任何支持ODBC的数据库进行连接
//m_pConnection->ConnectionString="Provider=SQLOLEDB.1; Persist Security Info=True; User ID=sa; Password=a1!; Initial Catalog=InTouch; Data Source=WIN-P6OLLUM9PDM"; //请将数据库相应ID与Password更改
//不通过DSN对SQL SERVER数据库进行连接
m_pConnection->ConnectionString="driver={SQL Server};Server=127.0.0.1;DATABASE=InTouch;UID=sa;PWD=a1!";
//连接服务器和数据库
HRESULT hr=m_pConnection->Open("", "", "", 0);
if(hr!=S_OK)
cout<<"Can not connect to the specified database!"<<endl;
}
catch(_com_error e){
cout<<e.Description()<<endl;
}
}
开发者ID:mz247,项目名称:C-C-,代码行数:22,代码来源:adoConnectSQL.cpp
示例18: GetADOErrors
void RxADO::GetADOErrors(_com_error eErrors)
{
ErrorsPtr pErrors=cnn->GetErrors();
if (pErrors->GetCount()==0)
MessageBox(NULL,eErrors.ErrorMessage(),"´í Îó",MB_OK|MB_ICONEXCLAMATION);
else
{
for (int i=0;i<pErrors->GetCount();i++)
{
_bstr_t desc=pErrors->GetItem((long)i)->GetDescription();
MessageBox(NULL,desc,"´í Îó",MB_OK|MB_ICONEXCLAMATION);
}
}
}
开发者ID:ice98,项目名称:mycode_bak,代码行数:14,代码来源:RxADO.cpp
示例19: GetRecordset
_RecordsetPtr& GetRecordset(_bstr_t SQL)
{
m_pRecordset=NULL;
try{
if(m_pConnection==NULL)
//连接
Connect();
m_pRecordset.CreateInstance(__uuidof(Recordset));
m_pRecordset->Open((_bstr_t)SQL, m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText);
}
catch(_com_error e){
cout<<e.Description()<<endl;
m_pRecordset=NULL;
return m_pRecordset;
}
return m_pRecordset;
}
开发者ID:mz247,项目名称:C-C-,代码行数:17,代码来源:adoConnectSQL.cpp
示例20: OnBnClickedButtonSearch
void CDlgHistory::OnBnClickedButtonSearch()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
GetDlgItem(IDC_BUTTON_SEARCH)->EnableWindow(FALSE);
CString AntID,SensorID,StrStartTime,StrStopTime;
m_CtlChart.GetToolBar(0).DoButtonClickResume();
m_CtlChart.GetYAxis(0).SetSpan(100);
m_CtlChart.GetYAxis(0).SetMin(0);
m_CtlChart.GetXAxis(0).SetMin(72686);
m_CtlChart.GetXAxis(0).SetSpan(0.00694444444444444);
m_CtlChart.GetChannel(0).Clear();
AntID.Format("%d",nIndexAnt+1);
AntID="天线"+AntID;
SensorID.Format("%d",nIndexSensor+1);
SensorID="传感器"+SensorID;
StrStartTime.Format("%f",m_DataBegin);
StrStopTime.Format("%f",m_DataEnding);
_bstr_t bstrSQLdata ="SELECT Temperature,RecordTime FROM DB_Data where ReaderID='"+strReader+"' and AntID='"+AntID+"' and SensorID='"+SensorID+"' and RecordTime<"+StrStopTime+" and RecordTime>"+StrStartTime+" and (Notes='正常') order by DataID;";
_RecordsetPtr m_pRecordsetch;
m_pRecordsetch.CreateInstance(__uuidof(Recordset));
m_pRecordsetch->Open(bstrSQLdata,m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
if (!m_pRecordsetch->adoEOF)
{
while(!m_pRecordsetch->adoEOF)
{
CString temper=(LPCSTR)(_bstr_t)m_pRecordsetch->GetCollect("Temperature");
CString time=(LPCSTR)(_bstr_t)m_pRecordsetch->GetCollect("RecordTime");
temper.ReleaseBuffer();
m_CtlChart.GetChannel(0).AddXY(atof(time), atof(temper) / 10);
m_pRecordsetch->MoveNext();
}
GetDlgItem(IDC_BUTTON_SEARCH)->EnableWindow(TRUE);
m_CtlChart.GetYAxis(0).ZoomToFitFast();
}
else
{
GetDlgItem(IDC_BUTTON_SEARCH)->EnableWindow(TRUE);
AfxMessageBox("查询不到数据!");
}
m_pRecordsetch->Close();
}
开发者ID:duoniduoni,项目名称:TempDetection,代码行数:44,代码来源:DlgHistory.cpp
注:本文中的_ConnectionPtr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论