1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// ouvrir la base
// chemin de la base
AnsiString FileName = "C:\\Classeur1.xls";
ADOConnection1->Close();
ADOConnection1->ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileName + ";Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1\"";
ADOConnection1->Connected = true;
ADOConnection1->Open();
ADOTable1->TableName = "Feuil1$";
ADOTable1->Open();
Edit1->Text = ADOTable1->FindField("Nom")->AsString;
//Edit1->Text = ADOTable1->Fields->Fields[1]->AsString;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
// enregistrement suivant
if(!ADOTable1->Eof)
{
ADOTable1->Next();
Edit1->Text = ADOTable1->FindField("Nom")->AsString;
}
else
{
Beep(500, 100);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
// enregistrement precedent
if(!ADOTable1->Bof)
{
ADOTable1->Prior();
Edit1->Text = ADOTable1->FindField("Nom")->AsString;
}
else
{
Beep(500, 100);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
// rechercher
String text = Edit2->Text;
ADOTable1->Filter = "";
ADOTable1->Sort = "Nom ASC"; // ASCendant ou DESCendant
// loCaseInsensitive ne tient pas compte de la Casse
// loPartialKey recherche sur une clef partielle
ADOTable1->Locate("Nom", text, TLocateOptions() << loCaseInsensitive << loPartialKey);
Edit1->Text = ADOTable1->FindField("Nom")->AsString;
}
//--------------------------------------------------------------------------- |
Partager