Trying to fully copy a database into a new one to no avail

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
newyuppie
Posts: 13
Joined: Fri 07 Jul 2006 05:48

Trying to fully copy a database into a new one to no avail

Post by newyuppie » Sat 07 Oct 2006 05:42

im trying to use MySQLDump to achieve this but im finding it very hard to do.
i need to duplicate a "master" database which is on the server into a new database, with everything from triggers to stores procedures.

if i use the .ExportAll = TRUE option to export the triggers and procedures i find i can't actually achieve what i want. the .DumpText shows that when i use ExportAll it has a statement of the sort USE [fromdb] instead of the USE [todb] that i need.

i've tried to play with settings for over an hour, including the .Database setting, .Connection.Database setting, etc. the documentation is actually not very clear on this issue and the Intellisense neither. e.g. if i type MySQLDump.Database, intellisense says "get or set database to dump data from".

so it would make sense to me to have my connection open to my TODATABASE database, assign this connection to the dump, assign the .Database property of the Dump to my FROMDATABASE. this doesnt work like i expect actually.

would you please direct me on how to proceed to achieve this that i want? summing it up: i have a "master" database which i need to duplicate in its entirety to another newly created database, triggers and procedures and all. i would like the dump to have the create database statements for the new db and drop tables that already exist. i also don't want to store the dump in a text file and make modifications to it, i would like it all to be in memory, very fast.

thanks for your help
P

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Mon 09 Oct 2006 08:46

Did you read about MySqlDump component in MySQLDirect help documentation? There are code examples in it.

newyuppie
Posts: 13
Joined: Fri 07 Jul 2006 05:48

yes

Post by newyuppie » Mon 09 Oct 2006 23:48

yes i read the documentation and because i did not find what i was looking for i came to the forums. i dont see any more than 1 example and it doesnt address my issue.

i will rephrase the question:
i need to backup a database in memory in order to create a new database. but i need to backup triggers and procedures too. setting .IncludeALL to true will not only include triggers and procedures, but will also insert this in the beginning:

use [fromdb];

which does not happen when i set IncludeALL to false. that little line causes that i backup from a database and restore to the same database no matter what .Database is set to.

i am using MySQLDump not to backup a database, but to DUPLICATE a database into another. what i need help with is achieving this because i wasnt able to find help for this specific issue in the documentation. maybe im misinterpreting the properties and what they do, or maybe im just plain wrong. i would appreciate any suggestions
thanks

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Tue 10 Oct 2006 06:36

i need to backup a database in memory in order to create a new database.
Database is backed up into DumpText property which, of course, is stored in memory.
i need to backup triggers and procedures too.
As stated in documentation, ExportAll propertry determines whether to export functions, procedures, and views together with tables. Judging from the fact that triggers are not enumerated there, they are not dumped.
"use [fromdb];" line causes that i backup from a database and restore to the same database no matter what .Database is set to.
You can change that line yourself or completely erase it from DumpText property.

newyuppie
Posts: 13
Joined: Fri 07 Jul 2006 05:48

Post by newyuppie » Wed 11 Oct 2006 06:09

Alexey wrote:
"use [fromdb];" line causes that i backup from a database and restore to the same database no matter what .Database is set to.
You can change that line yourself or completely erase it from DumpText property.
how do i erase that line from the DumpText property, having .ExportAll set to True that seems not possible. Please assist me how to do this

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Wed 11 Oct 2006 06:52

Use the following code string:

Code: Select all

mySqlDump1.DumpText = mySqlDump1.DumpText.Substring(0, mySqlDump1.DumpText.IndexOf("use [fromdb];")) + mySqlDump1.DumpText.Substring(mySqlDump1.DumpText.IndexOf("use [fromdb];") + "use [fromdb];".Length);

Post Reply