本文整理汇总了C++中_ConnectionPtr::GetInterfacePtr方法的典型用法代码示例。如果您正苦于以下问题:C++ _ConnectionPtr::GetInterfacePtr方法的具体用法?C++ _ConnectionPtr::GetInterfacePtr怎么用?C++ _ConnectionPtr::GetInterfacePtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_ConnectionPtr
的用法示例。
在下文中一共展示了_ConnectionPtr::GetInterfacePtr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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();
}
示例3:
// 打开记录集
_RecordsetPtr& ADOConn::GetRecordSet(_bstr_t bstrSQL)
{
//TODO: insert return statement here
try
{
if (m_pConnection==NULL)
{
OnInitADOConn();
}
//创建记录对象
m_pRecordset.CreateInstance(__uuidof(Recordset));
//取得表中记录
m_pRecordset->Open(bstrSQL,m_pConnection.GetInterfacePtr(),adOpenDynamic,
adLockOptimistic,adCmdText);
}
catch (_com_error e)
{
e.Description();
}
return m_pRecordset;
}
示例4: 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"));
//.........这里部分代码省略.........
示例5: OnBnClickedButtonExport
void CDlgHistory::OnBnClickedButtonExport()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
GetDlgItem(IDC_BUTTON_EXPORT)->EnableWindow(FALSE);
COleVariant covTrue((short)TRUE),covFalse((short)FALSE),covOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
book.PrintPreview(_variant_t(false));
CFileDialog FileDialog(FALSE,"xlsx",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("Microsoft Excel 2007(*.xlsx)|*.xlsx|所有文件(*.*)"),this);
if(FileDialog.DoModal()!=IDOK)
{
GetDlgItem(IDC_BUTTON_EXPORT)->EnableWindow(TRUE);
return;
}
CString cStrFile=FileDialog.GetPathName(); //选择保存路径名称
if(::PathFileExists(cStrFile))
DeleteFile(cStrFile);
CString AntID,SensorID,StrStartTime,StrStopTime,tmpData,passWord,StartTime,StopTime,message,strRecordTime,rowCount,strRow,strLimit;
StrStartTime.Format("%f",m_DataBegin);
StrStopTime.Format("%f",m_DataEnding);
CTime m_Startdate;
m_CtlDateTimeStartTime.GetTime(m_Startdate);
StartTime.Format("%d%02d%02d",m_Startdate.GetYear(), m_Startdate.GetMonth(),m_Startdate.GetDay());
_RecordsetPtr m_pRecordsetch;
m_pRecordsetch.CreateInstance(__uuidof(Recordset));
books = app.get_Workbooks();
book = books.Add(covOptional);
sheets = book.get_Worksheets();
sheets.Add(vtMissing,vtMissing,vtMissing,vtMissing);
int nCount;
char cCell;
for(int i=1;i<5;i++)
{
tmpData.Format("%d",i);
AntID = "天线"+tmpData;
sheet = sheets.get_Item(COleVariant((short)i)); //得到第一个工作表
sheet.put_Name(AntID);
for(int j=1;j<13;j++)
{
nCount = 3;
tmpData.Format("%d",j);
SensorID = "传感器"+tmpData;
cCell = 'A' + 2*(j-1);
rowCount.Format(_T("%c"),cCell);
rowCount+="1";
range = sheet.get_Range(COleVariant(rowCount),COleVariant(rowCount));
range.put_Value2(COleVariant(SensorID));
rowCount.Format(_T("%c"),cCell);
rowCount+="2";
range = sheet.get_Range(COleVariant(rowCount),COleVariant(rowCount));
range.put_Value2(COleVariant("时间"));
rowCount.Format(_T("%c"),cCell+1);
rowCount+="2";
range = sheet.get_Range(COleVariant(rowCount),COleVariant(rowCount));
range.put_Value2(COleVariant("温度"));
_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='正常' or Notes='超限') order by DataID;";
m_pRecordsetch->Open(bstrSQLdata,m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
while(!m_pRecordsetch->adoEOF)
{
CString temper=(LPCSTR)(_bstr_t)m_pRecordsetch->GetCollect("Temperature");
CString time=(LPCSTR)(_bstr_t)m_pRecordsetch->GetCollect("RecordTime");
COleDateTime t=atof(time);
strRecordTime=t.Format("%Y-%m-%d %H:%M:%S");
rowCount.Format(_T("%c"),cCell);
strRow.Format(_T("%d"),nCount);
rowCount+=strRow;
range = sheet.get_Range(COleVariant(rowCount),COleVariant(rowCount));
range.put_NumberFormat(COleVariant("hh:mm:ss"));
range.put_Value2(COleVariant(strRecordTime)); //设置时间
rowCount.Format(_T("%c"),cCell+1);
rowCount+=strRow;
range = sheet.get_Range(COleVariant(rowCount),COleVariant(rowCount));
range.put_Value2(COleVariant(temper)); //设置温度
time.ReleaseBuffer();
temper.ReleaseBuffer();
m_pRecordsetch->MoveNext();
nCount++;
}
m_pRecordsetch->Close();
}
range = sheet.get_Range(COleVariant("A3"),COleVariant("A3"));
COleVariant vResult =range.get_Value2();
if(vResult.vt==VT_EMPTY)
{
passWord="19700101hshiot";
}
else
{
SYSTEMTIME st;
VariantTimeToSystemTime(vResult.date, &st);
passWord.Format("%d%02d%02d",st.wYear,st.wMonth,st.wDay);
passWord+="hshiot";
}
sheet.Protect(_variant_t(passWord),vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing);
}
book.SaveCopyAs(COleVariant(cStrFile)); //保存到cStrFile文件
book.put_Saved(true);
books.Close();
book.ReleaseDispatch();
books.ReleaseDispatch();
app.ReleaseDispatch();
//.........这里部分代码省略.........
示例6: SaveSlideData
void CBacilusDetectDoc::SaveSlideData()
{
CString sql;
m_pRs->raw_Close();
sql.Format(_T("select *from BacilusDetect.dbo.PatientPerInfo where SlideID = '%s'"),m_SlideBoxData.SlideInfo.strSlideID);
m_pRs->Open((_variant_t)sql,m_pCon.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
if(m_pRs->adoEOF)//如果之前没有SlideID信息则
{
try
{
m_pRs->raw_Close();
//病人个人信息表
m_pRs->Open("SELECT * FROM BacilusDetect.dbo.PatientPerInfo",_variant_t((IDispatch*)m_pCon),adOpenStatic,adLockOptimistic,adCmdText);
m_pRs->AddNew();//添加一条新记录
m_pRs->Fields->GetItem(_variant_t("Name"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strName;
m_pRs->Fields->GetItem(_variant_t("PatientID"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strPatientID;
m_pRs->Fields->GetItem(_variant_t("Department"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strDepartment;
m_pRs->Fields->GetItem(_variant_t("BedID"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strBedID;
m_pRs->Fields->GetItem(_variant_t("Gender"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.nGender;
m_pRs->Fields->GetItem(_variant_t("Year"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.nYear;
m_pRs->Fields->GetItem(_variant_t("Occupation"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strOccupation;
m_pRs->Fields->GetItem(_variant_t("Telephone"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strTelephone;
m_pRs->Fields->GetItem(_variant_t("Address"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strAddress;
m_pRs->Fields->GetItem(_variant_t("SlideID"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strSlideID;
m_pRs->Update();
AfxMessageBox(_T("病人个人信息表保存成功!"));
}
catch(...)
{
AfxMessageBox(_T("病人个人信息表保存失败!"));
}
try
{
m_pRs->raw_Close();
//病人玻片信息表
m_pRs->Open("SELECT * FROM BacilusDetect.dbo.PatientSlideInfo",_variant_t((IDispatch*)m_pCon),adOpenStatic,adLockOptimistic,adCmdText);
m_pRs->AddNew();//添加一条新记录
m_pRs->Fields->GetItem(_variant_t("SlideID"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strSlideID;
m_pRs->Fields->GetItem(_variant_t("Type"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strType;
_variant_t var;
var.vt=VT_DATE;
var.date=int(m_SlideBoxData.SlideInfo.dtDetectData);
m_pRs->Fields->GetItem(_variant_t("DetectData"))->Value=(_bstr_t)var;
_variant_t vart;
vart.vt=VT_DATE;
vart.date=DATE(m_SlideBoxData.SlideInfo.dtDetectTime);
m_pRs->Fields->GetItem(_variant_t("DetectTime"))->Value=(_bstr_t)vart;
m_pRs->Fields->GetItem(_variant_t("Quantity"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strQuantity;
m_pRs->Fields->GetItem(_variant_t("StayTime"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strStayTime;
m_pRs->Fields->GetItem(_variant_t("Method"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strMethod;
m_pRs->Fields->GetItem(_variant_t("SendDoctor"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strSendDoctor;
m_pRs->Fields->GetItem(_variant_t("Judge"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strJudge;
m_pRs->Fields->GetItem(_variant_t("DetectResult"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strDetectResult;
m_pRs->Fields->GetItem(_variant_t("BacilusDensity"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strBacilusDensity;
m_pRs->Fields->GetItem(_variant_t("FOVCount"))->Value=(_bstr_t)m_SlideBoxData.nFOVCount;
m_pRs->Fields->GetItem(_variant_t("bScan"))->Value=(_bstr_t)m_SlideBoxData.bScan;
m_pRs->Fields->GetItem(_variant_t("bJudge"))->Value=(_bstr_t)m_SlideBoxData.bJudge;
m_pRs->Fields->GetItem(_variant_t("TargetCount"))->Value=(_bstr_t)GetTargetCountInSlide();
m_pRs->Fields->GetItem(_variant_t("JudgedTargetCount"))->Value=(_bstr_t)GetJudgedTargetCountInSlide();
m_pRs->Update();
AfxMessageBox(_T("病人玻片信息表保存成功!"));
}
catch(...)
{
AfxMessageBox(_T("病人玻片信息表保存失败!"));
}
try
{
m_pRs->raw_Close();
//病人报告信息表
m_pRs->Open("SELECT * FROM BacilusDetect.dbo.PatientRepInfo",_variant_t((IDispatch*)m_pCon),adOpenStatic,adLockOptimistic,adCmdText);
m_pRs->AddNew();//添加一条新记录
m_pRs->Fields->GetItem(_variant_t("ReportDoctor"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strReportDoctor;
_variant_t varr;
varr.vt=VT_DATE;
varr.date=int(m_SlideBoxData.SlideInfo.dtReportData);
m_pRs->Fields->GetItem(_variant_t("ReportData"))->Value=(_bstr_t)varr;
m_pRs->Fields->GetItem(_variant_t("CompareJudge"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strCompareJudge;
m_pRs->Fields->GetItem(_variant_t("CompareDetectResult"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strCompareDetectResult;
m_pRs->Fields->GetItem(_variant_t("CompareBacilusDensity"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strCompareBacilusDensity;
m_pRs->Fields->GetItem(_variant_t("SlideID"))->Value=(_bstr_t)m_SlideBoxData.SlideInfo.strSlideID;
_variant_t var;
var.vt=VT_DATE;
var.date=int(m_SlideBoxData.SlideInfo.dtDetectData);
m_pRs->Fields->GetItem(_variant_t("DetectData"))->Value=(_bstr_t)var;
_variant_t vart;
vart.vt=VT_DATE;
vart.date=DATE(m_SlideBoxData.SlideInfo.dtDetectTime);
m_pRs->Fields->GetItem(_variant_t("DetectTime"))->Value=(_bstr_t)vart;
//.........这里部分代码省略.........