?
Solved

Save DBgrid to file (MySql)

Posted on 2004-10-05
7
Medium Priority
?
542 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
[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 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 2

Accepted Solution

by:
cqhall earned 150 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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 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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month8 days, 19 hours left to enroll

764 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