Stdafx.h
Stdafx.h
Libado.h
Libado.h
Libado.cpp
Libado.cpp
The reference URL is as follows: http://www.cnblogs.com/livewithnorest/p/3316886.html
The use of the class library file is as follows:
Ado.init (); Ado. Connect (ADO. Oracle); //--------Query Example start--------STD::stringsql ="SELECT * FROM username"; Adoreader=ADO. ExecuteReader (SQL); _variant_t Strz,value; CString Stry; intNitem =0; _RecordsetPtr m_recordsetptr=adoreader.m_recordsetptr; Fieldsptr FLDS= M_recordsetptr->getfields ();//get the number of columns in a table_variant_t Index; INDEX.VT=Vt_i2; //--------Add header header dynamically start--------//m_listctrl->insertcolumn (0, "serial number", lvcfmt_left,50); for(inti =0;i< (int) Flds->getcount (); i++) {Index.ival=i; //M_listctrl->insertcolumn (i+1, (LPSTR) Flds->getitem (Index)->getname (), lvcfmt_left,100); } //--------Add header title end dynamically--------//--------Add row data start-------- while(m_recordsetptr->adoeof = = FALSE)//m_precordset->adoeof{stry. Format (_t ("%d"), nitem+1); //M_listctrl->insertitem (nitem,stry); for(inti =0; I < (int) m_recordsetptr->fields->count;i++) {Index.ival=i; Strz= Flds->getitem (Index)GetName (); Value= m_recordsetptr->Getcollect (STRZ); if(VALUE.VT! =vt_null) { //M_listctrl->setitemtext (nitem,i+1, (LPCSTR) (_bstr_t) value); } Else { //M_listctrl->setitemtext (Nitem,i+1, "");}} m_recordsetptr-MoveNext (); Nitem++; } m_recordsetptr-Close (); Adoreader.recordclose (); //--------Add row data end--------//--------Query Example End--------//--------New example Start--------STD::stringsql ="INSERT into username (id,name) VALUES (' 4 ', ' name4 ')"; intRET =0; RET=ADO. ExecuteNonQuery (SQL); //--------New Example End--------//--------Editing example start--------sql ="Update username set name= ' Namemax ' where id= ' 4 '"; RET=ADO. ExecuteNonQuery (SQL); //--------Editing example end--------//--------Delete example start--------sql ="Delete from username where id= ' 4 '"; RET=ADO. ExecuteNonQuery (SQL); //--------Delete The example end--------
MFC ADO Connection ORACLE12C database class library file