Generating a Database Via a Live Connection by Script

You can generate a database via ODBC using script.

To do so, you first begin with connecting to the database using the ConnectToDatabase(ByVal Dsn As String, ByVal User As String, ByVal Password As String) As Boolean method from the model, then you set up the generation options and launch the generation feature.

For more information about the generation options, see section BasePhysicalPackageOptions in the Metamodel Object Help file.

Example:

Const cnxDSN = "ODBC:ASA 9.0 sample"
Const cnxUSR = "dba"
Const cnxPWD = "sql"

Const GenDir = "C:\temp\"
Const GenFile = "test.sql"
Const ModelFile = "C:\temp\phys.pdm"

set pModel = openModel(ModelFile)

 set pOpts=pModel.GetPackageOptions()
 
  pModel.ConnectToDatabase cnxDSN, cnxUSR, cnxPWD
  pOpts.GenerateODBC = true
 
 pOpts.GenerationPathName = GenDir
 pOpts.GenerationScriptName = 'script.sql"
 pModel.GenerateDatabase