ConnectServer

Method
Connects to a database server.

Category
Database

 

Syntax
Sub ConnectServer(ByVal ServerName As String, ByVal NetType As String)

ServerName
The name of the server to connect to.

NetType
The network protocol to use for network communication.

Value:

Means:

netb

Use NetBIOS for network communication.

tcp

Use TCP/IP for network communication.

 

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
The server must be running when you issue this call. All subsequent calls to access the database will be passed to the server, which will execute the operations.

This function is only applicable in a multiuser configuration.

To close the connection to a database server, call DisconnectServer.

An application can be connected to only one server at a time; use DisconnectServer before connecting to another. Applications can switch between a server connection and a locally-opened database (you can alternate between ConnectServer and OpenDatabase); remember to close the existing connection before making the switch.



© 2009 Microsoft Corporation. All rights reserved.