Creating a Database

Example 1

Consider an example of database creation in a repository based on Oracle 9.x server.

Sub Main;

Var

MB: IMetabase;

CrInfo: IMetabaseObjectCreateInfo;

DB: IDatabase;

Begin

MB := MetabaseClass.Active;

CrInfo := MB.CreateCreateInfo;

CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_DATABASE;

CrInfo.Id := "NewDatabase";

CrInfo. Name: = "New database";

CrInfo.Parent := MB.Root;

DB := MB.CreateObject(CrInfo).Edit As IDatabase;

DB.Authentication := AuthenticationMode.Password;

DB.DriverId := "ORCL8";

DB.LogonData.ParamValue("SERVER") := "Test";

DB.LogonData.ParamValue("SCHEME") := "TestShema";

DB.LoginPrompt := False;

DB.Credentials.SlotValue("USERNAME") := "User";

DB.Credentials.SlotValue("PASSWORD") := "Password";

(DB As IMetabaseObject).Save;

End Sub Main;

After executing the example, a new database is created in repository root. The database is set up to connection to the TestShema scheme. The scheme is located on Oracle server with the Test name. Automatic connection to the scheme with the following credentials is used: user name - User; password - Password.

Example 2

Consider an example of database creation in a repository based on Microsoft SQL Server 2008 server.

Sub Main;

Var

MB: IMetabase;

CrInfo: IMetabaseObjectCreateInfo;

DB: IDatabase;

Begin

MB := MetabaseClass.Active;

CrInfo := MB.CreateCreateInfo;

CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_DATABASE;

CrInfo.Id := "NewDatabase";

CrInfo. Name: = "New database";

CrInfo.Parent := MB.Root;

DB := MB.CreateObject(CrInfo).Edit As IDatabase;

DB.Authentication := AuthenticationMode.Password;

DB.DriverId := "MSSQL2008";

DB.LogonData.ParamValue("SERVER") := "Test";

DB.LogonData.ParamValue("DATABASE") := "TestShema";

DB.LoginPrompt := False;

DB.Credentials.SlotValue("USERNAME") := "User";

DB.Credentials.SlotValue("PASSWORD") := "Password";

(DB As IMetabaseObject).Save;

End Sub Main;

After executing the example, a new database is created in repository root. The database is set up to connection to the TestShema scheme. The scheme is located on Microsoft SQL Server 2008 server with the Test name. Automatic connection to the scheme with the following credentials is used: user name - User; password - Password.

See also:

Examples