ADO way access to a password database

zhaozj2021-02-16  42

Main code:

CString strsql; tchar filename [max_path], errmsg [MAX_PATH];

:: Coinitialize (NULL); // Initialization COM

IADORecordBinding * picRs = NULL; _RecordsetPtr pRs ( "ADODB.Recordset"); _ConnectionPtr pConn ( "ADODB.Connection"); // CFootballTeamRs rsFootballTeam; GetModuleFileName (NULL, FileName, MAX_PATH); (_tcsrchr (FileName, '//') [1] = 0;

LSTRCAT (FileName, _T ("pass.mdb");

STRSQL = strsql "provider = microsoft.jet.Oledb.4.0;" "data source =" filename "; persist security info = false; Jet OLEDB: Database Password = CD;";

// pconn-> connectionstring = chDataSource; // pconn-> provider = _t ("Microsoft.jet.OleDb.4.0"); cstring sqlsence = _t ("select * from pass"); try {pconn-> open (( _BSTR_T) STRSQL, "", "", AdmodeunkNown;

PRS-> Queryinterface (__UUIDOF (Iadorecordbinding), (LPVOID *) & PICRS);

pRs-> Open ((_variant_t) sqlSentence, // Search fields pConn.GetInterfacePtr DemoTable table () // Get IDispatch pointer adOpenDynamic library access library, adLockOptimistic, adCmdText);} catch (_com_error & e) {sprintf (errMsg , _T ("CODE Meaning =% S / N"), (char *) E.ErrorMessage ()); afxMessageBox (Errmsg); PRS-> Close (); PCONN-> Close (); :: couninitialize () ;: Return;}

Try {while (! (prs-> endoffile) {cstring pass = (lpctstr) (_ bstr_t) PRS-> getCollect ("pass"); if (pass.isempty ()) return; setdlgitemtext (IDC_Pass, pass); PRS -> MoveNext (); // Break;} PRS-> Close (); pconn-> close ();} catch (_com_error & e) {sprintf (errmsg, _t ("code meaning =% s / n"), CHAR *) E.ErrorMessage ()); AfxMessageBox (Errmsg); PRS-> Close (); pconn-> close (); :: couninitialize (); return;} couninitialize ();

转载请注明原文地址:https://www.9cbs.com/read-25874.html

New Post(0)