::CoInitialize(0); //vc6以上用此语句初始
//创建数据库连接
m_pConnection.CreateInstance("ADODB.Connection");
m_pConnection->Open("Provider=SQLOLEDB.1; Server=10.8.100.34;Database=test; uid=st; pwd=st","","",adModeUnknown);
//创建数据集
m_pRecordset.CreateInstance("ADODB.Recordset");
m_pRecordset->Open("SELECT * FROM userinfo",_variant_t((IDispatch *)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
_variant_t vID,vName;
vID = m_pRecordset->GetCollect("ID");//取得字段的值
vName=m_pRecordset->GetCollect("Name");
MFC以ADO方式连接SQL数据库
最新推荐文章于 2020-10-02 11:19:09 发布