| Home | Previous Lesson: Building Distributed PowerBuilder Applications Next Lesson: Creating the Remote Object |
Select File > New menu option and double click on Standard Class icon located under Object tab page and select Connection and click OK button.
Define a function of_GetConnectionInfo function as shown below.
// Object: nco_connection
// Function: of_GetConnectionInfo
// Access: protected
// Returns: integer
// Arguments:
// as_server, string, by reference
// as_driver, string, by reference
// as_location, string, by reference
// server: PMSServer, Driver: WinSock, Location: localhost
CONSTANT string LS_REGKEY = "HKEY_CURRENT_USER\Software\asi\pms\DPB"
RegistryGet( LS_REGKEY, "Server", RegString!, as_server )
RegistryGet( LS_REGKEY, "Driver", RegString!, as_driver )
RegistryGet( LS_REGKEY, "Location", RegString!, as_location )
Return 1
This function reads values from the registry. You need to define those registry entries and set the values as listed in the comments. The next function calls this function.
// Object: nco_connection
// Function: of_ConnectToServer
// Access: public
// Returns: integer
// Arguments: None
string ls_server, ls_driver, ls_location
long ll_rc
If of_GetConnectionInfo( ls_server, ls_driver, ls_location ) = 1 Then
this.Application = ls_server
this.Driver = ls_driver
this.UserID = SQLCA.UserID
this.Password = SQLCA.DBPass
this.Location = ls_location
ll_rc = This.ConnectToServer()
IF ll_rc <> 0 THEN
MessageBox("DPB", "Cannot connect to server: #" + string(ll_rc))
RETURN -1
END IF
RETURN 1
End If
return �1
The above function is calling of_GetConnectionInfo and connecting to the DPB server by calling ConnectToServer() function. Please note that we are using the UserID and Password from the SQLCA object and we are not storing them in the registry. Save this object as nuo_connection.
| Home | Previous Lesson: Building Distributed PowerBuilder Applications Next Lesson: Creating the Remote Object |