• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

Delphi data base

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
ypenia
Asked:
ypenia
  • 7
  • 7
1 Solution
 
Geert GOracle dbaCommented:
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
 
ypeniaAuthor Commented:
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
 
Geert GOracle dbaCommented:
using a database engine, but you don't want to do that, now do you ?
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
ypeniaAuthor Commented:
thats mean that i have to install the engine on each computer ?
0
 
Geert GOracle dbaCommented:
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
 
Geert GOracle dbaCommented:
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
 
ypeniaAuthor Commented:
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
 
ypeniaAuthor Commented:
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
 
Geert GOracle dbaCommented:
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
 
ypeniaAuthor Commented:
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
 
Geert GOracle dbaCommented:
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
 
ypeniaAuthor Commented:
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
 
Geert GOracle dbaCommented:
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
 
ypeniaAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 7
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now