Use native ADO to perform data storage, this example can be displayed, page down, but there is a problem with the top page. The modified storage, deletion, etc. have problems, and all friends have modified it, I only give the role of a throwing brick.
//.cpp program
/ / -------------------------------------------------------------------------------------------- ---------------------------
#include
#include "unit1.h" // --------------------------------------- ---------------------------------- # Pragma package (smart_init) #pragma resource "* .dfm" #include
TFORM1 * FORM1; / / -------------------------------------------- -------------------------------__ fastcall tform1 :: tform1 (tComponent * Owner): TFORM (OWNER) {} // -------------------------------------------------- -------------------------
void __fastcall TForm1 :: Button1Click (TObject * Sender) {VConnect = CreateOleObject ( "ADODB.Connection"); // open connection VConnect.OleFunction ( "Open", "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D : //ado//bcdemos.mdb; Persist security info = false ");} // ----------------------------- ----------------------------------------------
void __fastcall TForm1 :: Button2Click (TObject * Sender) {VRecordSet = CreateOleObject ( "ADODB.RecordSet"); VRecordSet.OlePropertySet ( "ActiveConnection", VConnect); // set the command type and content VRecordSet.OleFunction ( "Open", "Select * from Employee", vconnect); // Execute instruction showrecord ();} // --------------------------- --------------------------------------------- Void TFORM1 :: ShowRecord () {txtEmpNo-> Text = VarToStr (VRecordSet.OlePropertyGet ( "Fields", "EmpNo")); txtLastName-> Text = VarToStr (VRecordSet.OlePropertyGet ( "Fields", "LastName")); txtFirstName-> Text = VarToStr (VRecordSet.OlePropertyGet ( "Fields", "FirstName")); txtPhone-> Text = VarToStr (VRecordSet.OlePropertyGet ( "Fields", "PhoneExt")); txtHireDate-> Text = VarToStr (VRecordSet.OlePropertyGet ( " Fields "," HireDate ")); txtSalary-> Text = VarToStr (VRecordSet.OlePropertyGet (" Fields "," Salary "));} void __fastcall TForm1 :: Button3Click (TObject * Sender) {VRecordSet.OleFunction (" Update " , "Lastname", txtlastname-> text);} // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------- --------------------------- void __fastcall tform1 :: button4click (TOBJECT * Sender) {if (! VRecordSet.olePropertyget ("bof") ) {VRecordset.olefunction ("MoveFirst"); showrecord ();}} // --------------------------------------------- --------------------------------------------
Void __fastcall tform1 :: button6click (TOBJECT * sender) {if (! VRecordSet.olePropertyget ("bof")) {vRecordset.olefunction ("moveprevious"); showrecord ();}} // -------- -------------------------------------------------- -----------------
Void __fastcall tform1 :: button7click (TOBJECT * Sender) {if (! VRecordset.olePropertyget ("eof")) {vrecordset.olefunction ("MoveNext"); showrecord ();}} // ---------- -------------------------------------------------- ----------------- void __fastcall tform1 :: button5click (Tobject * sender) {// if (! VRecordSet.olePropertyget ("EOF") {vRecordSet.OLEFUNCTION ("MoveLast "); Showrecord (); //}} // ------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//.h program
/ / -------------------------------------------------------------------------------------------- ---------------------------
#ifndef unit1H # Define unit1H // ------------------------------------------------------------------------------------------------------------------------------------ --------------------------------- # include