Connect Method for LCConnection
This method establishes a connection to a connector. Multiple connections may be independently established to a single connector.
For the Connector for DB2®, this method establishes a connection to DB2® using required properties Database, UserName, and Password.
If the connection attempt fails, an error will occur. Refer to the section on "Error Messages" for possible errors.
Defined In
LCConnection
Syntax
lcConnection.Connect
Example
Option Public
Uselsx "*lsxlc"
Sub Initialize
Dim connect As New LCConnection ("db2")
' set the appropriate properties to connect to DB2
' note the use of dynamic properties to do this
' all properties of a connection may be referenced
' by name
connect.Database = "Gold"
connect.Userid = "JDoe"
connect.Password = "xyzzy"
' try the connect
On error go to Trap
connect.Connect
Print "Successfully connected to DB2."
Exit Sub
Trap:
Print "Connection failed with error " & err & ": " & error
Exit Sub
End Sub
Example Output
Successfully connected to DB2.