Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help a newbie start a database project ...!!!

Status
Not open for further replies.

clifff

Programmer
Mar 22, 2002
20
MD
Hi everybody! I am new to the C++ Builder & teck tips forum. I have to design a database project (standalone application). Where to start ? I found soemething about BDE relation between TDataSet, TDataSource, Data controls but how to make all this staff to work I dont know... Can anyone help me? I would like to see a simple project if it is possible :). Any suggestion are welcome!

Thanks, clifff.
 
faq 101-536

see my faq in the faq's tab. Wim Vanherp
Wim.Vanherp@belgacom.net
 
I put this to gether to translate the banking history
file that I download from my bank to a table.
It is probably dificult to follow because some of
the work is done in the forms setup. If you will
follow the function calls that refer to "Table" in
your help files you will begin to make sense of it
maybe.

Please excuse my style, no formal training.

//-----------------------------------------------------
#include <vcl.h>
#include <dir.h>
#include <stdio.h>

#pragma hdrstop

#include &quot;qif.h&quot;
#include &quot;report.h&quot;
//------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;
//--------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
// Set the DatabaseName to the current working directory.
char *buff1 = new char [256];
getcwd(buff1, 256);
Table1->Active = false;
Table1->DatabaseName = buff1;

// If the database file is not present, create it.
if (!FileExists (&quot;bnk.dbf&quot;))
Table1->CreateTable ();

Table1->Active = true;

// Clean up.
delete (buff1);
}
//---------------------------------------------------
void __fastcall TForm1::OpenClick(TObject *Sender)
{
// Set the start directory
char *buff1 = new char [256];
getcwd(buff1, 256);
OpenDialog->InitialDir = buff1;
//delete (buff1);

if (OpenDialog->Execute ())
{
strcpy (filename, OpenDialog->FileName.c_str ());

Form1->Caption = filename;

FILE *file;
int x = 0;

if ( (file = fopen(filename, &quot;r&quot;)) != NULL )
{
Table1->Active = false;
Table1->EmptyTable ();
Table1->Active = true;

while (!feof(file))
{
fgets(buff1, 256, file);

Table1->Insert();

for (; x < 5; x++)
{
fgets(buff1, 256, file);
int z = strlen (buff1);
int y = 0;
for (; y < z; y++)
{
buff1 [y] = buff1 [y + 1];
}
buff1 [y - 2] = NULL;

Table1->Fields[x]->AsString = buff1;
}

Table1->Post();

x = 0;

Table1->Next();
}
}
else
Application->MessageBox(&quot;File access error&quot;, &quot;FILE ERROR&quot;, MB_OK);
}
}
//------------------------------------------------


void __fastcall TForm1::FormResize(TObject *Sender)
{
DBGrid1->Height = Form1->Height - 50;
Form1->Width = 507;
}
//------------------------------------------

void __fastcall TForm1::ExitClick(TObject *Sender)
{
Application->Terminate ();
}
//------------------------------------------

void __fastcall TForm1::previewClick(TObject *Sender)
{
ReportForm->Table1->Active = true;
ReportForm->QuickRep1->Preview ();
ReportForm->Table1->Active = false;
}
//----------------------------------------------

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top