Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Delphi data base

Posted on 2009-05-14
15
Medium Priority
?
252 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
[X]
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
  • 7
  • 7
15 Comments
 
LVL 38

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 38

Expert Comment

by:Geert Gruwez
ID: 24384160
using a database engine, but you don't want to do that, now do you ?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

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

Accepted Solution

by:
Geert Gruwez earned 1200 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 38

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 38

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 38

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 38

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

604 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