OpenDatabase

Method
Opens a database file.

Category
Database

 

Syntax
Sub OpenDatabase(ByVal DatabaseName As String, ByVal CacheSize As Long, ByVal UseCommitCache As Boolean)

DatabaseName
The database that is to be to opened.

CacheSize
The size of the cache in KB.

UseCommitCache
Whether to use CommitCache or not.

 

Example

'Testing functions connectserver, servername or

'databasename, getdatabasename, opendatabase

  If .Text1(cf.ServerName) <> "" Then

  CF1.ConnectServer .Text1(cf.ServerName).Text, "tcp" '

  logWr "Connected to Server"

  Else

  'Open database

  tmpLong = 2000 'cache size

  tmpLong2 = 0 'commitcache or not

  FunctionInput = .Text1(cf.DatabaseName).Text

  If CF1.GetDatabaseName(FunctionInput) Then

  logWr "GetDatabaseName with closed DB failed"

  End

  Else

  logWr "GetDatabaseName with closed DB: OK"

  End If

  CF1.openDatabase .Text1(cf.DatabaseName).Text, tmpLong, tmpLong2

  If CF1.GetDatabaseName(FunctionInput) Then

  logWr "GetDatabaseName with open DB: OK"

  Else

  logWr "GetDatabaseName with open DB failed"

  End

  End If

  logWr "Database Opened"

  End If

 

Comments
OpenDatabase opens a database with a cache of the size specified in CacheSize and loads the database manager. All subsequent calls to access the database are passed to the database manager, which executes the operations.

A cache is an area of RAM that holds the results of recent disk accesses. CacheSize specifies the amount of memory assigned to the disk cache that is used by the database manager when it accesses the database file. The size depends on which operating system is being used. As a general rule, the larger the cache, the better the performance. For more information about cache size and performance, see the Installation and System Management: Microsoft Business Solutions–Navision Database Server manual.

There are no restrictions on opening a database, but access to the tables can be governed by a password. See Login.

Close the database by calling CloseDatabase. An application can have only one database open at a time. Use CloseDatabase before opening another database. Applications can switch between a server connection and a locally-opened database (use ConnectServer , OpenDatabase and ConnectServerandOpenDatabase); remember to close the current connection before making the switch.

C/FRONT does not support the use of extended characters in directory and database names.



© 2009 Microsoft Corporation. All rights reserved.