博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ADO查询站SQLServer,字段类型
阅读量:4045 次
发布时间:2019-05-24

本文共 1840 字,大约阅读时间需要 6 分钟。

2014年3月29日10:29:19

ADO查询站SQLServer,字段类型

_ConnectionPtr pStationConnection = NULL;//连接    	_RecordsetPtr  pStationRecordset = NULL;//记录集 	pStationConnection.CreateInstance(__uuidof(Connection));    	pStationRecordset.CreateInstance(__uuidof(Recordset)); 	//CString sInfo;  	try    	{   		_bstr_t strConnect =_T("Driver=SQL Server;Server=192.168.4.186,1433;Database=DBETC;UID=sa;PWD=123"); 		pStationConnection->Open(strConnect, _T(""),_T(""), adModeUnknown);    		sInfo.Format(_T("连接站库成功"));  	}catch (_com_error e)    	{  		sInfo.Format(_T("连接站库失败"));  	}    	DBG_AfxMessageBox(sInfo);	StationExitRec aRec;	//站SQL Server	_bstr_t bstrSQL(_T("SELECT TOP 1 * FROM SEXIT2013090100007 WHERE ExitLane>1000 AND transfermark%16=0"));  	try  	{  		pStationRecordset->Open(bstrSQL, pStationConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText);  		_variant_t var;  		int nSn = 0;int nSn1 = 0;int nSn2 = 0;		CString str;		CString str1;		CString str2;		if(!pStationRecordset->EndOfFile)  		{ 			var = pStationRecordset->GetCollect(_T("ExitLane"));//smallint			if((var.vt == VT_I2) || var.vt == VT_I4)			{				nSn = var.intVal;			}			var = pStationRecordset->GetCollect(_T("entryshift"));//tinyint			if((var.vt == VT_I2) || var.vt == VT_I4)			{				nSn1 = var.intVal;			}			var = pStationRecordset->GetCollect(_T("recordno"));//int			if((var.vt == VT_I2) || var.vt == VT_I4)			{				nSn2 = var.intVal;			} 			var = pStationRecordset->GetCollect(_T("MVlicense"));//Varchar			if(var.vt == VT_BSTR)			{				str1 = var.bstrVal;			}			var = pStationRecordset->GetCollect(_T("ProgramStartTime"));//datetime 			if(var.vt == VT_DATE)			{				str2 = COleDateTime(var).Format(); 			}			str.Format(_T("SN:%d,str1:%s,str2:%s"),nSn,str1,str2);			DBG_AfxMessageBox(str);  		}  		pStationRecordset->Close();  	}catch (_com_error  e)  	{  		exit(-1);  	}

转载地址:http://xjwci.baihongyu.com/

你可能感兴趣的文章
Linux 粘滞位 suid sgid
查看>>
C#控件集DotNetBar安装及破解
查看>>
Winform皮肤控件IrisSkin4.dll使用
查看>>
Winform多线程
查看>>
C# 托管与非托管
查看>>
Node.js中的事件驱动编程详解
查看>>
mongodb 命令
查看>>
MongoDB基本使用
查看>>
mongodb管理与安全认证
查看>>
nodejs内存控制
查看>>
nodejs Stream使用中的陷阱
查看>>
MongoDB 数据文件备份与恢复
查看>>
数据库索引介绍及使用
查看>>
MongoDB数据库插入、更新和删除操作详解
查看>>
MongoDB文档(Document)全局唯一ID的设计思路
查看>>
mongoDB简介
查看>>
nodejs 浏览器弹窗下载图片 data:image/jpeg;base64示例
查看>>
JAVA实现AES加密
查看>>
JAVA实现DES加密
查看>>
关于AES256算法java端加密,ios端解密出现无法解密问题的解决方案
查看>>