PreviousDTO Programmer's Guide (9.1 revision 1) Next

DtoDatabase Object

Show this topic in Library frames
Properties

DataPath
Gets or sets the location of the data for a database.
DbFlags
Gets or sets the database flags for a database. This property is an enumeration. See Database Flags for a list of possible values.
DdfPath
Gets or sets the dictionary path for a database.
Name
Gets or sets the name of the database.
Secured
Returns whether the database has security enabled. (0=unsecure, 1=secure)
Session
Gets or sets the Session object associated with this DtoDatabase object.

Collections
DtoTables Collection 
Methods
Open method 
Close method 
Copy method 
Secure method 
UnSecure method 
Remarks

The Secure and UnSecure methods can only be used when the database is closed.

Example
' instantiate session object and connect to server 
Dim my_session as New DtoSession 
Dim result as DtoResult 
result = my_session.Connect("myserver", "username", 
"password") 
' now use your session object to obtain db collection 
Dim my_databases as DtoDatabases 
Set my_databases = my_session.Databases 
' get first database and query its dictionary path 
Dim first_database as DtoDatabase 
Dim dictionarypath as string 
Set first_database = my_databases(1) 
dictionarypath = first_database.DdfPath 
See Also

DtoDatabases Collection
DtoDictionary Object

Methods Detail

Open method

Opens a connection to the database with the given username and password.

Syntax
result = Object.Open(username, password) 
Arguments

Object
DtoDatabase object
username
User name for the database. If database is not secured, set to an empty string.
password
Password for the database. If database is not secured, set to an empty string

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.

Remarks

This operation is used in order to open a set of dictionary files. This set must contain FILE.DDF, INDEX.DDF and FIELD.DDF. It may also contain a number of optional DDF files. Remember to call the Close method to free memory. Once the database is opened, no one else can make changes to it until the Close method is called.

You cannot issue the Secure or UnSecure methods while the database is open.

More information on the errors returned by the method can be obtained using the Error property of the DtoSession Object.

Example
Dim m_session as new DtoSession 
Dim m_database as new DtoDatabase 
Dim result as DtoResult 
result = m_session.Connect("myserver","user","pwd") 
m_database.Session = m_session 
m_database.Name = "DEMODATA" 
result = m_database.Open("dbuser","pwd") 

Close method

Closes a set of data dictionary files that were opened using the Open method.

Syntax
result = Object.Close 
Arguments

Object
DtoDatabase object

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.

Remarks

Call this method after the database has been opened using Open method. Error information can be obtained using Error property.

Example
Dim m_database as new DtoDatabase 
Dim result as DtoResult 
result = m_database.Open("dbuser","pwd") 
' perform operations here 
' 
result = m_database.Close 

Copy method

Creates a new database based on the current one.

Syntax
result = Object.Copy(username, password, newDBname, 
newDictionaryPath, newDataPath) 
Arguments

Object
DtoDatabase object
username
Database user name for the database. If the database does not have security enabled, set to an empty string.
password
Password for database user. If the database does not have security enabled, set to an empty string.
newDBname
Database name for the copied database.
newDictionaryPath
Absolute path to the directory in which the dictionary files are to be created. This directory must already exist.
newDataPath
Data path for the database. Pass an empty string to use the default data path (that is, the same as the dictionary path)

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.

Remarks

Referential integrity is preserved in the copied database.

More information on the errors returned by the method can be obtained using the Error property.

Example
Dim Database As New DtoDatabase 
Dim result as DtoResult 
Database.Session = my_session ` assume session exists 
Database.Name = "DEMODATA" 
` no user name or password, unsecure database 
result = Database.Copy("", "", "DEMODATA2", 
"C:\PVSW\DEMODATA2", "C:\PVSW\DEMODATA2") 
If NOT result = Dto_Success Then 
  MsgBox "Error"+ Session.Error(result) 
End If 

Secure method

Enables security for a database.

Syntax
result = Object.Secure(user, password) 
Arguments

Object
DtoDatabase object
user
User should be set to "Master" for securing the database.
password
Password for the Master user.

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.

Remarks

When you enable database security, you must specify Master as the database user name and choose a password. Security for the database is enforced based on the access rights defined for the database, and should match behavior seen in SQL or ODBC interfaces.

Ensure that the database is closed when attempting to enable security.

More information on the errors returned by the method can be obtained using the Error property of the DtoSession Object.

Example
Dim m_database as new DtoDatabase 
Dim result as DtoResult 
m_database.Name = "DEMODATA" 
m_database.Session = my_session ` assume session exists 
result = m_database.Secure("Master", "password") 

UnSecure method

Disables security for a database.

Syntax
result = Object.UnSecure(user, password) 
Arguments

Object
DtoDatabase object
user
User should be set to "Master" for unsecuring the database.
password
Password for the Master user.

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.

Remarks

When you disable database security, you must specify Master as the database user name and provide the Master user password.

Ensure that the database is closed when attempting to disable security.

More information on the errors returned by the method can be obtained using the Error property of the DtoSession Object.

Example
Dim m_database as new DtoDatabase 
Dim result as DtoResult 
m_database.Name = "DEMODATA" 
m_database.Session = my_session ` assume session exists 
result = m_database.UnSecure("Master", "password") 

Chapter contents
Publication contents

Prev topic: DtoDatabases Collection
Next topic: DtoDSNs Collection