Exemplo n.º 1
0
//断开连接
void ExitConnect(void)
{
	if(m_pRecordset!=NULL){
		m_pRecordset->Close();
		m_pConnection->Close();
	}
	::CoUninitialize();  //释放环境
}
Exemplo n.º 2
0
void ADOConn::ExitConnect(void)
{
//关闭记录集和连接
if (m_pRecordset!=NULL)
{
m_pRecordset->Close();
 
}
m_pConnection->Close();
::CoUninitialize();
}
Exemplo n.º 3
0
//断开指定数据库连接对象连接
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;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
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;

			//添加系统时间
			COleDateTime   oletimeVar=COleDateTime::GetCurrentTime();
			_variant_t   vars;   					
			vars.vt=VT_DATE;   
			vars.date=DATE(oletimeVar);   // 给oletimeVar赋值;   
			m_pRs->Fields->GetItem(_variant_t("ReportTime"))->Value=_bstr_t(vars);
			m_pRs->Update();
		 AfxMessageBox(_T("病人报告信息表保存成功!"));
		}
	   catch(...)
	   {
		AfxMessageBox(_T("病人报告信息表保存失败!"));
	   }
	   	
	 //图片信息表

	  //     LARGE_INTEGER       t0;
		 //  LARGE_INTEGER       t1;
		 //  LARGE_INTEGER       frequency;
		 //  QueryPerformanceFrequency(&frequency);
		 //  QueryPerformanceCounter(&t0);
	  //    for(int nFOVIndex=0;nFOVIndex<m_SlideBoxData[nWorkPositionIndex].nFOVCount;nFOVIndex++)
		 // { 
			//try
			//{
			///*	CString str;
			//	str.Format(_T("\\%d.JPG"), nFOVIndex);*/
			//	
			//	CFile f;
			//	CFileException e;
			//	CString str;
	
			//	str.Format(_T("\\%d.JPG"), nFOVIndex);
			//	f.Open((GetDirectory(nWorkPositionIndex)+str), CFile::modeRead | CFile::typeBinary, &e); //打开指定的图像文件
			//
			//	int nSize = f.GetLength();          //先得到 图像 文件长度
			//		
			//	BYTE* pBuffer = new BYTE [nSize];   //按文件的大小在堆上申请一块内存 pBuffer
			//	
			//	if (f.Read(pBuffer, nSize) > 0 )
			//	{
			//		//BYTE* pBuf = pBuffer;			//下面这一大段是把pBuffer里的图像数据放到库中
			//		//VARIANT	varBLOB;		
			//		//SAFEARRAY *psa;
			//		//SAFEARRAYBOUND rgsabound[1];
			//		//if(pBuf)
			//		//{    
			//		//	rgsabound[0].lLbound = 0;
			//		//	rgsabound[0].cElements = nSize;
			//		//							
			//		//	psa = SafeArrayCreate(VT_UI1, 1, rgsabound); // 创建 SAFEARRAY 对象 psa
			//		//	for (long i = 0; i < (long)nSize; i++)
			//		//	SafeArrayPutElement (psa, &i, pBuf++);	 // 将 bBuf 指向的二进制数据
			//		//												// 保存到 psa 中
			//		//	varBLOB.vt = VT_ARRAY | VT_UI1;	// 将 varBLOB 类型设为 BYTE 类型数组
			//		//	varBLOB.parray = psa;			// 保存 psa 到 varBLOB
			//		//}   
			//			CString strbyte;
			//			strbyte.Format(_T("%s"),pBuffer);

			//			_variant_t var;
			//			var.vt=VT_DATE;
			//			var.date=int(m_SlideBoxData[nWorkPositionIndex].SlideInfo.dtDetectData); 

			//			_variant_t vart;
			//			vart.vt=VT_DATE;
			//			vart.date=DATE(m_SlideBoxData[nWorkPositionIndex].SlideInfo.dtDetectTime);

	  // 					m_pRs->raw_Close();
			//			sql.Format(_T("insert into BacilusDetect.dbo.PictureInfo values('%s','%s','%s',%d,%d,%d,%d,%f,%f,%f,CAST('%s' as image))"),
			//						   m_SlideBoxData[nWorkPositionIndex].SlideInfo.strSlideID,(LPCTSTR)(_bstr_t)var,(LPCTSTR)(_bstr_t)vart,nFOVIndex,GetTargetCountInFOV(nWorkPositionIndex, nFOVIndex),
			//						   GetJudgedTargetCountInFOV(nWorkPositionIndex, nFOVIndex),GetFOVCheckedStatus(nWorkPositionIndex, nFOVIndex),
			//						   m_SlideBoxData[nWorkPositionIndex].TargetInFOV[nFOVIndex].FOVPosition.x,m_SlideBoxData[nWorkPositionIndex].TargetInFOV[nFOVIndex].FOVPosition.y,
			//						   m_SlideBoxData[nWorkPositionIndex].TargetInFOV[nFOVIndex].FOVPosition.z,strbyte);
			//			/*m_pRs->raw_Close();
			//			sql.Format(_T("insert into BacilusDetect.dbo.Text values(newid (),1,CAST('%s' as varbinary(max)))"),(GetDirectory(nWorkPositionIndex)+str));*/
			//			m_pRs->Open((_bstr_t)sql,m_pCon.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
			//    }
			//}
			//catch(...)
			//{
			//	AfxMessageBox(_T("图片信息表保存失败!"));
			//}	
		 // }
		 //   QueryPerformanceCounter(&t1);
			//double  timespan = (double) (t1.QuadPart - t0.QuadPart) / frequency.QuadPart;
			//CString string;
			//string.Format(_T("%f"), timespan);
			//AfxMessageBox(string);


    LARGE_INTEGER       t0;
	LARGE_INTEGER       t1;
	LARGE_INTEGER       frequency;
	QueryPerformanceFrequency(&frequency);
	QueryPerformanceCounter(&t0);
	 m_pRs->raw_Close();	 
	 m_pRs->Open ("ChartInfo", _variant_t((IDispatch *) m_pCon, true), adOpenStatic, adLockOptimistic, adCmdTable);
	/* for(int nFOVIndex=0;nFOVIndex<m_SlideBoxData[nWorkPositionIndex].nFOVCount;nFOVIndex++)
	 {	*/     
		 //try
		 //    {	
			//  				
			//	CString str;	
			//	str.Format(_T("\\%d.JPG"), nFOVIndex);//GetDirectory(nWorkPositionIndex)+str			
			//
			//		    
			//		    
			//			//图片信息表				
			//			
			//			m_pRs->AddNew();//添加一条新记录               
			//			
		 //  				m_pRs->Fields->GetItem(_variant_t("SlideID"))->Value=(_bstr_t)m_SlideBoxData[nWorkPositionIndex].SlideInfo.strSlideID;
			//			
			//			_variant_t var;
			//			var.vt=VT_DATE;
			//			var.date=int(m_SlideBoxData[nWorkPositionIndex].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[nWorkPositionIndex].SlideInfo.dtDetectTime); 
			//			m_pRs->Fields->GetItem(_variant_t("DetectTime"))->Value=(_bstr_t)vart;
			//			m_pRs->Fields->GetItem(_variant_t("PictureID"))->Value=(_bstr_t)nFOVIndex;
			//			m_pRs->Fields->GetItem(_variant_t("TargetCount"))->Value=(_bstr_t)GetTargetCountInFOV(nWorkPositionIndex, nFOVIndex);
			//			m_pRs->Fields->GetItem(_variant_t("JudgedTargetCount"))->Value=(_bstr_t)GetJudgedTargetCountInFOV(nWorkPositionIndex, nFOVIndex);
			//			m_pRs->Fields->GetItem(_variant_t("bChecked"))->Value=(_bstr_t)GetFOVCheckedStatus(nWorkPositionIndex, nFOVIndex);
			//			
			//			m_pRs->Fields->GetItem(_variant_t("FOVPositionX"))->Value=(_bstr_t)m_SlideBoxData[nWorkPositionIndex].TargetInFOV[nFOVIndex].FOVPosition.x;
			//	        m_pRs->Fields->GetItem(_variant_t("FOVPositionY"))->Value=(_bstr_t)m_SlideBoxData[nWorkPositionIndex].TargetInFOV[nFOVIndex].FOVPosition.y;
			//	        m_pRs->Fields->GetItem(_variant_t("FOVPositionZ"))->Value=(_bstr_t)m_SlideBoxData[nWorkPositionIndex].TargetInFOV[nFOVIndex].FOVPosition.z;
			//									
			//			m_pRs->Update(); 

			//			if(nFOVIndex==m_SlideBoxData[nWorkPositionIndex].nFOVCount-1)
			//			{
			//				AfxMessageBox(_T("图片信息表保存成功!"));
			//			}
			//			
			//			
			//	}		   

			//   catch(...)
			//   {
			//	 AfxMessageBox(_T("图片信息表保存失败!"));
			//   }

			SQLCHAR transactionToken[32];
    
			SQLHANDLE henv  = SQL_NULL_HANDLE;
			SQLHANDLE hdbc  = SQL_NULL_HANDLE;
			SQLHANDLE hstmt = SQL_NULL_HANDLE;

			LARGE_INTEGER  t3,t4, Frequency;
			double totaltime = 0;
			QueryPerformanceFrequency(&Frequency);
			QueryPerformanceCounter(&t3);
	
			try
			{
						//These statements Initialize ODBC for the client application and
						//connect to the database.

						if ( SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv) != SQL_SUCCESS )
							throw new ODBCErrors(__LINE__, SQL_HANDLE_ENV, henv);

						if ( SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION,(void*)SQL_OV_ODBC3, NULL) != SQL_SUCCESS )
							throw new ODBCErrors(__LINE__, SQL_HANDLE_ENV, henv);

						if ( SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc) != SQL_SUCCESS )
							throw new ODBCErrors(__LINE__, SQL_HANDLE_ENV, henv);

						//This code assumes that the dataset name "Sql Server FILESTREAM"
						//has been previously created on the client computer system. An
						//ODBC DSN is created with the ODBC Data Source item in
						//the Windows Control Panel.

						if ( SQLConnect(hdbc, TEXT("BacilusDetect"),//这里是数据源
								SQL_NTS, NULL, 0, NULL, 0) <= 0 )
							throw new ODBCErrors(__LINE__, SQL_HANDLE_DBC, hdbc);

						//FILESTREAM requires that all read and write operations occur
						//within a transaction.
						if ( SQLSetConnectAttr(hdbc,
							SQL_ATTR_AUTOCOMMIT,
							(SQLPOINTER)SQL_AUTOCOMMIT_OFF,
							SQL_IS_UINTEGER) != SQL_SUCCESS )
							throw new ODBCErrors(__LINE__, SQL_HANDLE_DBC, hdbc);

						if ( SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt) != SQL_SUCCESS )
							throw new ODBCErrors(__LINE__, SQL_HANDLE_DBC, hdbc);

						SQLUSMALLINT mode = SQL_COMMIT;
						SQLINTEGER cbTransactionToken;
						TCHAR dstFilePath[1024];
						SQLINTEGER cbDstFilePath;
						wchar_t sqlDBQuery[1024];

						for ( int nFOVIndex=0;nFOVIndex<m_SlideBoxData.nFOVCount;nFOVIndex++)
						{
							_variant_t var;
							var.vt=VT_DATE;
							var.date=int(m_SlideBoxData.SlideInfo.dtDetectData); 
			
							_variant_t vart;
							vart.vt=VT_DATE;
							vart.date=DATE(m_SlideBoxData.SlideInfo.dtDetectTime); 

							CString str;	
			                str.Format(_T("\\%d.JPG"), nFOVIndex);//GetDirectory(nWorkPositionIndex)+str
							
							//swprintf_s(sqlDBQuery, 1024, L"INSERT INTO BacilusDetect.dbo.ChartInfo(SlideID,DetectData,DetectTime,PictureID,TargetCount,JudgedTargetCount,bChecked,FOVPositionX,FOVPositionY,FOVPositionZ,Id,Chart)\
							//			OUTPUT GET_FILESTREAM_TRANSACTION_CONTEXT(), inserted.Chart.PathName()\
							//			VALUES (%s,CONVERT(date, '%s'),CONVERT(datetime, '%s'),%d,%d,%d,%d,%f,%f,%f,newid(), CONVERT(VARBINARY, '**Temp**'))",m_SlideBoxData[nWorkPositionIndex].SlideInfo.strSlideID,
							//			m_SlideBoxData[nWorkPositionIndex].SlideInfo.dtDetectData,m_SlideBoxData[nWorkPositionIndex].SlideInfo.dtDetectTime,nFOVIndex,GetTargetCountInFOV(nWorkPositionIndex, nFOVIndex),
							//			GetJudgedTargetCountInFOV(nWorkPositionIndex, nFOVIndex),GetFOVCheckedStatus(nWorkPositionIndex, nFOVIndex),m_SlideBoxData[nWorkPositionIndex].TargetInFOV[nFOVIndex].FOVPosition.x,
							//			m_SlideBoxData[nWorkPositionIndex].TargetInFOV[nFOVIndex].FOVPosition.y,m_SlideBoxData[nWorkPositionIndex].TargetInFOV[nFOVIndex].FOVPosition.z);

							swprintf_s(sqlDBQuery, 1024, L"INSERT INTO Archive.dbo.Records2(Id,SerialNumber,Chart,date1)\
										OUTPUT GET_FILESTREAM_TRANSACTION_CONTEXT(), inserted.Chart.PathName()\
										VALUES (newid(),23,CONVERT(VARBINARY, '**Temp**'),CONVERT(date, '2012-12-14'))");

							if ( SQLExecDirect(hstmt, sqlDBQuery, SQL_NTS) != SQL_SUCCESS )
								throw new ODBCErrors(__LINE__, SQL_HANDLE_STMT, hstmt);

							//Retrieve the transaction token.
							if ( SQLFetch(hstmt) != SQL_SUCCESS )
								throw new ODBCErrors(__LINE__, SQL_HANDLE_STMT, hstmt);

    						if ( SQLGetData(hstmt, 1,
								SQL_C_BINARY,
								transactionToken,
								sizeof(transactionToken),
								&cbTransactionToken) != SQL_SUCCESS )
								throw new ODBCErrors(__LINE__, SQL_HANDLE_STMT, hstmt);

							//Retrieve the file path for the inserted record.
							if ( SQLGetData(hstmt, 2, SQL_C_TCHAR, dstFilePath, sizeof(dstFilePath), &cbDstFilePath) != SQL_SUCCESS )
								throw new ODBCErrors(__LINE__, SQL_HANDLE_STMT, hstmt);

    						if ( SQLCloseCursor(hstmt) != SQL_SUCCESS )
								throw new ODBCErrors(__LINE__, SQL_HANDLE_STMT, hstmt);

							QueryPerformanceCounter(&t0);
							//if ( ! CopyFileToSQL( (LPTSTR)(LPCTSTR)(GetDirectory(nWorkPositionIndex)+str), dstFilePath, transactionToken, cbTransactionToken) )
							//{
							//	mode = SQL_ROLLBACK;
							//	break;
							//}
							QueryPerformanceCounter(&t1);
							double  timespan = (double) (t1.QuadPart - t0.QuadPart) / Frequency.QuadPart;
							totaltime += timespan;
						}
	
						SQLEndTran(SQL_HANDLE_DBC, hdbc, mode);	
					}
					catch(ODBCErrors *pErrors)
					{
						pErrors->Print();
						delete pErrors;
					}

					if ( hstmt != SQL_NULL_HANDLE )
						SQLFreeHandle(SQL_HANDLE_STMT, hstmt);

					if ( hdbc != SQL_NULL_HANDLE )
						SQLDisconnect(hdbc);

					if ( hdbc != SQL_NULL_HANDLE )
						SQLFreeHandle(SQL_HANDLE_DBC, hdbc); 

					if ( henv != SQL_NULL_HANDLE )
						SQLFreeHandle(SQL_HANDLE_ENV, henv);
	
					QueryPerformanceCounter(&t4);
					//wprintf_s(TEXT("Time: %f\n"), (double) (t4.QuadPart - t3.QuadPart) / Frequency.QuadPart);
					//wprintf_s(TEXT("Time: %f\n"), totaltime);
	
					if (m_pRs)
						if (m_pRs->State == adStateOpen)
							m_pRs->Close();
					if (m_pCon)
						if (m_pCon->State == adStateOpen)
							m_pCon->Close();
	
					::CoUninitialize();
					// TODO: 在此添加控件通知处理程序代码
					AfxMessageBox(_T("图像保存结束"));
	  
           
	 
      //细菌信息表
	  for(int nFOVIndex=0;nFOVIndex<m_SlideBoxData.nFOVCount;nFOVIndex++)
	 {	     
		     
		 for(int TargetCountIndex=0; TargetCountIndex<GetTargetCountInFOV( nFOVIndex);TargetCountIndex++)  
		 {
			 try
		    {	
				m_pRs->raw_Close();
				//细菌信息表
				m_pRs->Open("SELECT * FROM BacilusDetect.dbo.BacilusInfo",_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;
						
				_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("PictureID"))->Value=(_bstr_t)nFOVIndex;
				m_pRs->Fields->GetItem(_variant_t("BacilusID"))->Value=(_bstr_t)TargetCountIndex;				
				//m_pRs->Fields->GetItem(_variant_t("RPositionX"))->Value=(_bstr_t)m_SlideBoxData[nWorkPositionIndex].TargetInFOV[nFOVIndex].rectTarget[TargetCountIndex].x;
				//m_pRs->Fields->GetItem(_variant_t("RPositionY"))->Value=(_bstr_t)m_SlideBoxData[nWorkPositionIndex].TargetInFOV[nFOVIndex].rectTarget[TargetCountIndex].y;
				//m_pRs->Fields->GetItem(_variant_t("RPositionWidth"))->Value=(_bstr_t)m_SlideBoxData[nWorkPositionIndex].TargetInFOV[nFOVIndex].rectTarget[TargetCountIndex].width;
				//m_pRs->Fields->GetItem(_variant_t("RPositionHeight"))->Value=(_bstr_t)m_SlideBoxData[nWorkPositionIndex].TargetInFOV[nFOVIndex].rectTarget[TargetCountIndex].height;
				m_pRs->Update();
			}

			catch(...)
			{
				AfxMessageBox(_T("信息保存失败!"));
			}	   		 
		 }
	  }
	  AfxMessageBox(_T("信息保存成功!"));

	  }
	  else
	{
Exemplo n.º 6
0
void RxADO::Close()
{
	cnn->Close();
}