Solved

Save DBgrid to file (MySql)

Posted on 2004-10-05
7
514 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

20 Experts available now in Live!

Get 1:1 Help Now