10. Connect

[<<<] [>>>]

DB = ODBC::Connect(connection_name)

Use this fucntion to connect to an ODBC data source. The argument is the name of the connection as configured in the ScriptBasic configuration file.

Connection to an ODBC database usually requires a user name and password. Coding these into script source files may not be secure and thus this module allows the system manager to configure these codes in the ScriptBasic config file. This config file may not be readable by ordinary user and is binary in the form as read by the ScriptBasic interpreter. This adds some extra security.

Calling this function instead of RealConnect the programmer may reference a connection configured in the ScriptBasic configuration file. The key with the name of the connection should be under the key odbc.connections. For example:

odbc (
  connections (
    test (        ; the name of the connection
	  dsn "odbctest" ; data source name
	  user "" ; user for the connection, to test we use MS-Access thus there is no user or passwd
	  password "" ; password for the connection

When configuring such an ODBC connection do not forget to recompile the configuration file.

The name of the connection passed to the function should be the name used in the configuration file to identify the connection. In the example above this is test. This name need not, howeve may be the same as the data source name.

If the connection can not be established for some reason the function raises a module specific error.

See also RealConnect, Error.

The function calls the underlying ODBC function SQLAllocHandle and SQLConnect.

[<<<] [>>>]