_ConnectionPtr m_pconnection;
_RecordsetPtr m_precordset;
_variant_t RecordsAffected;
Cstrings STRSQL;
STRSQL. The Format (_T (" select * from wentidaninfo where maiid="lijiahua" "));
Try
{
M_pconnection. CreateInstance (" ADODB. Connection ");
M_pconnection - & gt; The ConnectionString=_T (" Provider=SQLOLEDB. 1; Integrated Security=SSPI; Persist Security Info=False; Data Source=QH - 20160810 ZMWN \ \ SQLEXPRESS ");
Retrieves the hr=m_pconnection - & gt; Open (" ", ""," ", adModeUnknown);
If (SUCCEEDED (hr))
{
HRESULT HRR=m_precordset. CreateInstance (__uuidof (you));
M_pconnection - & gt; Execute ((_bstr_t) STRSQL, & amp; RecordsAffected adCmdText);
While (m_precordset - & gt; AdoEOF)
{
AfxMessageBox (_T (" into the loop 1 "));
Int aa=0;
Cstrings SSS=(WCHAR *) _bstr_t (m_precordset - & gt; Kuidi GetCollect (" "));
M_precordset - & gt; MoveNext ();
}
}
}
Catch _com_error (e)
{
Cstrings ss;
Ss. The Format (_T (" connect to the database failed \ r \ n error message: % s "), (LPCTSTR) e.D escription ());
AfxMessageBox (ss);
}
CodePudding user response:
Present the wrong but I never close the object, high tried a day, can't think out
CodePudding user response:
M_precordset no call open open recordset, may have a look this case,