PModel.GenerateDatabase ' Launch the Generate Database featureĪfter, you modify the model by adding a column to each table: POpts.GenerationScriptName = "script.sql" ' Define sql file name POpts.GenerationPathName = GenDir ' Define generation directory POpts.GenerateODBC = False ' Force sql script generation rather than ' set generation options using model package options InteractiveMode = im_Batch ' Avoid displaying generate window Then you generate a script for this model in the folder defined in the "GenDir" constant using the following method: GenerateDatabase(ByVal ObjectSelection As BaseObject = Nothing).Īs you would do in the generation database dialog box, you have to define the generation directory and the sql file name before starting the generation, see the following example.ĭim pOpts : Set pOpts = pModel.GetPackageOptions() Then we are going to generate a database script for the model, modify the model, generate a modified data script, and generate a set of test data using respectively the following methods:ĭim fso : Set fso = CreateObject("Scripting.FileSystemObject")ĭim pModel : Set pModel = OpenModel(Modelfile)Įnd Sub Generating a script for the model In the following example, we begin with opening an existing model (ASA 9) using the following method: OpenModel (filename As String, flags As Long =omf_Default) As BaseObject.īe sure to add a final backslash (\) to the generation directory. GenerateTestData(ByVal ObjectSelection As BaseObject = Nothing).GenerateDatabase(ByVal ObjectSelection As BaseObject = Nothing).When you need to generate a database using script, you may use the following methods: