Use C++ and MySQL

I am setting up an agenda on C++ (use Borland Tubo C 2006), for to put my data I use a "StringGrid1", but I don't know save my data when I close my project.
I think a server should use, for example MySQL but I can not do.
You can see my line programming :

#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int recherche;
int drapeau;
const maxi=10;
typedef struct
{
AnsiString NOM;
AnsiString PRENOM;
AnsiString ADRESSE;
AnsiString NUM_TEL;
AnsiString MAIL;
}t_page;
typedef t_page t_agenda[maxi];
t_page page;
t_agenda agenda;
int numpage;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
memo1->Lines->Add("Bonjour");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
int i,j,k;
//for (i=0;i<StringGrid1->ColCount ;i++ )
for (j=1;j<StringGrid1->RowCount ;j++ )
{
numpage=0;
recherche=0;
drapeau=0;
Edit1->Text="" ;
Edit2->Text="" ;
Edit3->Text="" ;
Edit4->Text="" ;
Edit5->Text="" ;
StringGrid1->Cells[0][j]=IntToStr(j);
StringGrid1->Cells[i][1]=IntToStr(i);
StringGrid1->Cells[1][0]="NOM";
StringGrid1->Cells[2][0]="Prenom";
StringGrid1->Cells[3][0]="Adresse";
StringGrid1->Cells[4][0]="Tel";
StringGrid1->Cells[5][0]="@";

}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
if((Edit1->Text!="")&&(Edit2->Text!="")&&(Edit3->Text!="")
&&(Edit4->Text!="")&&(Edit5->Text!=""))
{
agenda[numpage].NOM=Edit1->Text ;
agenda[numpage].PRENOM=Edit2->Text ;
agenda[numpage].ADRESSE=Edit3->Text;
agenda[numpage].NUM_TEL=Edit4->Text;
agenda[numpage].MAIL=Edit5->Text;
Edit1->Text="" ;
Edit2->Text="" ;
Edit3->Text="" ;
Edit4->Text="" ;
Edit5->Text="" ;

numpage++;
}
else ShowMessage("entrer un NOM valide!!!!") ;

}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
{
//if ((Key==VK_RETURN)
// memo1->Lines->Text=Edit1->Text;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
int i;
for(i=0;i<numpage;i++)
{ StringGrid1->Cells[1][i+1]=agenda[i].NOM;
StringGrid1->Cells[2][i+1]=agenda[i].PRENOM;
StringGrid1->Cells[3][i+1]=agenda[i].ADRESSE;
StringGrid1->Cells[4][i+1]=agenda[i].NUM_TEL;
StringGrid1->Cells[5][i+1]=agenda[i].MAIL;
}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button6Click(TObject *Sender)
{
drapeau=recherche=0;
bool drapeau;

for(recherche=1;recherche<9;recherche++)
{
if (agenda[recherche-1].NOM==Edit6->Text)

{

drapeau=true;
TGridRect valeur;
valeur.Left=1;
valeur.Right=5;
valeur.Top=recherche;
valeur.Bottom=recherche;
StringGrid1->Selection=valeur;

}

}
if(drapeau==false)
ShowMessage("desolé ce nom n'existe pas");
}
Last edited on
Topic archived. No new replies allowed.