Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Save DBgrid to file (MySql)

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

610 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