To do this we will use the $DBWizAPI.ConnectPkg.Connect function, this function takes parameters as follows :
| Parameter | Comments |
|---|---|
| Connection Type | This is the constant for your database type, the constant name can be found in the $LLIAPI.DbInfoPkg.MapServerTypeFromString function, or if it is the same type as your Livelink database you can use the following $LLIAPI.DbInfoPkg.MapServerType($LLIAPI.DbInfoPkg.Findrec($Kernel.SystemPreferences.GetPrefGeneral( 'dftConnection' ))). |
| Server Name | For SQL Server databases this is the server name, for Oracle databases this is the TNS entry for the database. |
| Database Name | This is the name of the database that you wish to connect to. |
| Username | This is the username that should be used to connect to the database. |
| Password | This is the password for the above username. |
dynamic cnctVal1 // dynamic storing the database connection
// This code assumes that the DB is the same type as the Livelink DB
// Parameters are as follows :
// ConnectionType Integer Constant
// Server Name String
// Database Name String
// Username String
// Password String
cnctVal1 = $DBWizAPI.ConnectPkg.Connect(\
$LLIAPI.DbInfoPkg.MapServerType($LLIAPI.DbInfoPkg.Findrec($Kernel.SystemPreferences.GetPrefGeneral( 'dftConnection' ))),\
'myOracleServer',\
'myDB',\
'myUser',\
'myPassword' )
// disconnect from the DB
$DBWizAPI.ConnectPkg.Disconnect(cnctVal1.connect)