Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Delphi data base

Posted on 2009-05-14
15
247 Views
Last Modified: 2012-05-07
hello experts!!
I'v been tring to look for the best way to create a db based project using only delphi components, no mySql or any 3rd party involved. single file to containe all data.
my way was by creating 3 diff records but i couldn't save them into 1 single file and the delete is a hell of a problem.
the project is like a client db.
anyone can recommand for a way to do so or any tutorials that can help i'll be greatfull.
NOTE: i prefer keep using the records if anyone got the solution, since it's more easy to use (no need to install anything and i already have an encryption for it).

btw, i'm using delphi 2007 enterprise.
0
Comment
Question by:ypenia
  • 7
  • 7
15 Comments
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 24382727
well, try TClientDataset
for small database needs this may work.

this has some tutorials:
http://delphi.about.com/b/2005/03/29/a-guide-to-using-the-tclientdataset-in-delphi-applications-2.htm
0
 

Author Comment

by:ypenia
ID: 24383526
I liked the tutorials but still, how do i save several tables of diffrent data in the same file and load it from the same file.
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 24384160
using a database engine, but you don't want to do that, now do you ?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:ypenia
ID: 24384388
thats mean that i have to install the engine on each computer ?
0
 
LVL 37

Accepted Solution

by:
Geert Gruwez earned 300 total points
ID: 24384541
well, frankly ... yes
unless ... i came across this embedded db once ...
hold on to your socks:
here is a other solution
http://www.download3k.com/Press-Absolute-Database-5.03-Fast-reliable-embedded.html
and here is a summary of features:
http://www.componentace.com/bde_replacement_database_delphi_absolute_database.htm
    * No BDE; no DLLs
    * Single-file database
    * SQL'92 (DDL & DML) support
    * Compatible with standard and third-party database controls
    * Single-user and multi-user mode (file-server)
    * Works great on all versions of Windows - from 98 to Vista, doesn't require any updates or service packs
    * Ultra-fast in-memory tables
    * Unmatched ease-of-use
    * Strong encryption
    * BLOB compression
    * Free for personal use
    * Full source code available
    * Royalty-free distribution 

Open in new window

0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 24384973
Giving a B grade is accompanied as why the B grade was given
And i am missing the why ???

Otherwise change the grade to A, using the Request attention
0
 

Author Comment

by:ypenia
ID: 24392740
the Absolute controls are very good but i have to pay if iwant to use them in comercial. and its a 3rd party control.
i realy liked the TClientDataset but i cant save all tables into one single file :\

btw i already had the Absolute controls on my computer.
but it seems to be the only solution...  :\
0
 

Author Comment

by:ypenia
ID: 24392861
i think i know a solution tell me what you think
save each TClientDataSet  in a stream then puting all the stream in one stream and saving it to file..

bty i sent a Request attention
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 24401915
this means you will have to load all data at startup, and now and then save it all to file
what happens if a crash occurs ?
0
 

Author Comment

by:ypenia
ID: 24403871
you have a good point...
can i write stream to file ?
like file of record?
i have to find a way to do it.. :\
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 24403956
you can write nearly everything to a TFileStream
you would have to find a way to determine some starts and ends
do you know what a TStringlist is and what it can do ?

i don't work with TClientDataset (haven't tried it very much)
but if you want all in 1 file...
why not create 1 file from the separate files ?

trick below only works for text files (not binary)
const
  data_file_count = 3;
  data_files: array[1..data_file_count] of string ('customers', 'invoices', 'articles');
 
procedure Compact;
var List, Item: TStringList;
begin
  List := TStringList.Create;
  try
    Item := TStringList.Create;
    try
      for I := 1 to data_file_count do 
      begin
        Item.LoadFromFile(data_files[I]);
        List.Values[data_files[I]] := Item.DelimitedText; 
      end;
    finally
      Item.Free;
    end;
    List.SaveToFile('all_in_one');
  finally
    List.Free;
  end;
end;
 
procedure UnCompact;
var List, Item: TStringList;
begin
  List := TStringList.Create;
  try
    List.LoadFromFile('all_in_one');
    Item := TStringList.Create;
    try
      for I := 0 to List.Count-1 do 
      begin
        Item.DelimitedText := List.ValueFromIndex[I];
        Item.SaveToFile(List.Names[I]);
      end;
    finally
      Item.Free;
    end;
  finally
    List.Free;
  end;
end;

Open in new window

0
 

Author Comment

by:ypenia
ID: 24405218
first thanks for helping me
yeah i know tstringlist very well, but i still have to save it all for each change.
there is a way to write several records to one single file?
or somthing like that so when something change i dont have to save to whole file ?
just like the Absolute controls..

and again thanks for helping me after you got your points :)
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 24409364
that's exactly what a database engine does,
write only changed records away in files or in a single file.

I know it's a hassle to allways install a database client on a user pc.
But why reinvent the wheel ?
It's difficult stuff, you need to allocate space in the file and use direct access.
I don't have the time to do that.  
If i would i would probably sell it to you for a price ...
0
 

Author Comment

by:ypenia
ID: 24409467
i did it with record and its working very good even with encryption and the delete from file.. the only problem is saving to one single file for now its stored in one file for each record...

last question :D
i think i wrote it here befor
there is a way to write several records to one single file?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question