Solved

Save DBgrid to file (MySql)

Posted on 2004-10-05
7
515 Views
Last Modified: 2010-04-05
Hello,

I have to export a selection of fields and records of a database and save that selection to an MySql file. The problem is that on the computer where I have to make this selection, MySql is not installed.

The selection of the fields and the records of the used database are visible in a DBgrid. How can I export/save this selection to a MySql file without MySql installed on that computer. The solution should work stand-alone. I mean that it should work without the use of extra DLL, DBE, DBexpert, ...

I hope you understand what I mean.

All info welcome. Thanks.

Ka1a.

PS sorry for my poor English
0
Comment
Question by:ka1a
7 Comments
 
LVL 12

Expert Comment

by:esoftbg
ID: 12231212
DBgrid does visualization of the data provided to it through a DataSource from a DataSet connected to a DataBase (MySql). So I guess in your question the DataBase is on a remote machine where MySql is installed.
My advice is create a new MySql Database (file) on the remote Computer, then export/save this selection to that MySql file. After that you may Copy / Download the new MySql Database (file) which contains just exported / saved data into the Computer that has not MySql installed ....
0
 

Author Comment

by:ka1a
ID: 12236029
Thank you for youre reaction.

It is on the computer without MySql that the file has to be made. After that we send the file to someone else by email and he has to open the file with MySql. Is there a solution for this problem?

Thanks again.

Ka1a
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12237425
Yes, install MySQL... Otherwise you can never create the file.

But as a suggestion, consider saving the data to an XML file or plain CSV textfile. All the receiver would have to do is import the data in his database by any means.

If you don't have MySQL and don't want to have MySQL, then you cannot support MySQL...
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 12237452
0
 
LVL 2

Accepted Solution

by:
cqhall earned 50 total points
ID: 12311308
You could use a ClientDataset to make a portable dataset.  

If the structure is already defined in MySQL...
Add or use an existing tQuery control that retrieves the structure (and data, if desired) from MySQL
Add a tDataSetProvider and set its DataSset property to the tQuery
Add a tClientDataSet control and set its ProviderName property to the tDatasetProvider
Set the Active property of the tClientDataset control to true. It will open the tQuery, retrieve the records into memory and close the tQuery control.

If the structure is not already defined in MySQL, you'll need to create it yourself.  Cary Jensen has an extensive set of articles on the Borland Developers Network describing creating clientdataset structures at design time and runtime.

Let's call the MySQL computer "local" and the other computer "remote"

While at the local PC, call the ClientDataset's SaveToFile to create a binary or XML file, for example Portable.cds.
While at the remote PC, call the ClientDataSet's LoadFromFile(portable.cds) to retrieve the data, if any.  

I'm not sure what you mean by "selected" records.  If it is only some of the records that are in the local table, then you could have a second clientdataset with the same structure and copy only the "selected" records to it...

while not clientdataset1.eof do
begin
 if <condition is met> then
 begin
  clientdataset2.insert;
  for i:=0 to clientdataset1.fieldcount1 do
  begin
   clientdataset2.fields[i].value:=clientdataset1.fields[i].value;
  end;
 end;
 clientdataset1.next;
end;
clientdataset2.savetofile();

You will be able to add, remove and edit the records in the local ClientDataSet.  As long as you don't make the tQuery active on the remote PC, you won't need any database support except for midas.  You can compile the midslib.dcu unit into your application to avoid distributing mids.dll with your application.

Chuck
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Filemaker 14 vs Delphi Embarcadero 7 186
Delphi 10 Seattle Dataset Actions 5 79
Mobile Keyboard covers the display of the TMemo 3 78
JAudiorecorder record freezing the app 29 60
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 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

15 Experts available now in Live!

Get 1:1 Help Now