Solved

Delphi data base

Posted on 2009-05-14
15
245 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

813 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

10 Experts available now in Live!

Get 1:1 Help Now