CasewareDocs

AddDatabaseAt

Creates a database explicitly specifying the location: on Server or on Client. It is the way to create a database on server.

Compatibility

Available as of IDEA version 9.0

Syntax

AssDatabaseAt (databaseName As String, description As String, location As Integer)

Parameters

databaseName

Name of the database

description

Description of the database

location

Location of the new database

Remark

Location = 1 means ExecutionLocation.Server

Location = 0 means ExecutionLocation.Client

If called on server, only ExecutionLocation.Server is allowed; in this case it means regular server-side database creation.

If called on server and ExecutionLocation.Client is specified, an error is raised.

If called locally with ExecutionLocation.Client, it means regular local database creation.

If called locally with ExecutionLocation.Server, the database is created on the server only if the local project is linked to the server project. Otherwise an error is raised.

Example

Const CreateOnServer As Integer = 1

Const Create OnDesktop As Integer = 0

Dim SimpleCommands As Object

Dim dbData As String

Dim fName As String

Sub Main

Set SimpleCommands = SmartContext.MacroCommands.SimpleCommands
Set CreateDatabase = SmartContext.MacroCommands.CreateDatabase

fName = SimpleCommands.UniqueFileName("NewTestDatabase")
dbData = "1111;Create Database Test1#2222;Create Database Test2#3333;Create Database Test3"

'Creates a database with explicitly specifying the location.
CreateDatabase.AddDatabaseAt fName, ""; CreateOnServer
CreateDatabase.AddField "NUM_FIELD", "Field description (optional)", 4, 8, 2
CreateDatabase.AddField "CHAR_FIELD", "CHAR_FIELD_DESCR", 3, 32, 0
CreateDatabase.AppendValues dbData
CreateDatabase.PerformTask

'Release object
Set SimpleCommands = Nothing
Set CreateDatabase = Nothing
End Sub