Solved

Delphi data base

Posted on 2009-05-14
15
242 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
 

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now