1. Beatrix Willius
  2. Valentina Database ADK
  3. Mittwoch, August 24 2016, 08:24 AM
  4.  Abonnieren via E-Mail
How do I clone with a database parameter? I'm trying to change the segment size with cloning.

dim theDialog as new OpenDialog
theDialog.PromptText = kSelectClone
theDialog.Filter = FileTypes.DB
dim CloneFolderitem as FolderItem = theDialog.showModal
if CloneFolderitem = nil then Return

dim ValentinaDB as new VDatabase
ValentinaDB.open(CloneFolderitem)
if ValentinaDB = Nil then Break

theDatabase.Clone(ValentinaDB, True)

theDatabase is the database I want to clone. ValentinaDB is an database with only a schema and no records. However, no cloning is done. ValentinaDB is as empty as before.

What am I doing wrong? Valentina Studio doesn't support this type of cloning or I'd try it there.

As usual: Mac OS 10.11.6. Xojo 2016t1, Valentina latest.

Mit freundlichen Grüßen/Regards

Beatrix Willius

http://www.mothsoftware.com
Mail Archiver X: The email archiving solution for professionals
Kommentar
There are no comments made yet.
Ruslan Zasukhin Akzeptierte Antwort
Hi Beatrix,

You are very right using the second form of db.Clone()
"Clone( inTargetDb as VDatabase, inLoadRecords as Boolean = true )", REALconsoleSafe },

Just do not open target db, it not exists yet. Just assign into db object another segment size. Clone() will respect it.

dim targetDB as new VDatabase
targetDB.SegmentSize = your size

theDatabase.Clone(targetDB, True)
Kommentar
There are no comments made yet.
Beatrix Willius Akzeptierte Antwort
Hi Ruslan,

the code doesn't work. First it has me scratching my head because nowhere a folderitem for the location of the database is specified. Then I thought: better try it out. It gives an error "DB location is wrong." when doing the clone.

Bug or feature?

Mit freundlichen Grüßen/Regards

Beatrix Willius

http://www.mothsoftware.com
Mail Archiver X: The email archiving solution for professionals
Kommentar
There are no comments made yet.
Ruslan Zasukhin Akzeptierte Antwort
May be show your final version of code?
Kommentar
There are no comments made yet.
Beatrix Willius Akzeptierte Antwort
The code is identical to yours:

dim ValentinaDB as new VDatabase

theDatabase.Clone(ValentinaDB, True)

Regards

Beatrix Willius
Kommentar
There are no comments made yet.
Ivan Smahin Akzeptierte Antwort
This is a code which was added into V4RB tests:

dim clonedDb as VDatabase

// Create source database (mdb):
Test_VDatabase_Prepare()

// Prepare target db:
clonedDb = MakeNewDatabase()
dim location as FolderItem
location = GetFolderItem( "clone2_db" )
clonedDb.Create( location, EVDbMode.kDscDat_Blb_Ind )

// Clone:
mdb.Clone(clonedDb)

// Checks:
DO_TEST_EQ( clonedDb.TableCount(), 2 )

// Close target db:
CloseDatabase( clonedDb )
// Close source db:
Test_VDatabase_Cleanup()

It works without any problem.
Kommentar
There are no comments made yet.
Beatrix Willius Akzeptierte Antwort
Hi Ivan,

yes, your code works. Thanks!

Still this is the constructor with the folderitem and not the vDatabase. Does the second constructor work at all?

Mit freundlichen Grüßen/Regards

Beatrix Willius

http://www.mothsoftware.com
Mail Archiver X: The email archiving solution for professionals
Kommentar
There are no comments made yet.
Ruslan Zasukhin Akzeptierte Antwort
Hi Beatrix

mdb.Clone(clonedDb)

this is

VDatabase.Clone( VDatabase targetDB )

There is no FolderItem here
Kommentar
There are no comments made yet.
  • Seite :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 0 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories
Omegabundle
  1. 0 subcategories