Host database parameter
Description
If your DBMS supports it, specifies the workstation name when
connecting to the database in PowerBuilder. The Host parameter lets
you assign any 10–character label to identify the process
you are about to create when you connect to the database. This label
helps you distinguish your process from others running on the database
server.

You must specify the Host parameter before connecting
to the database in PowerBuilder.
Controls
-
ASE, SYC SAP Adaptive
Server Enterprise -
SNC SQL Native Client for Microsoft SQL Server
Syntax
1 |
Host='<span>workstation_name</span>' |
Default
None
Usage
For Adaptive Server, when you specify a value for Host, PowerBuilder sets
the CS_HOSTNAME connection property to the workstation
name you specify.
The value you specify for the Host parameter displays in the
hostname column of the MASTER.DBO.SYSPROCESSES table in a SQL Server database. How you use
the Host parameter depends on the design of your PowerBuilder application.
For example, many sites want to secure their production tables
so that updates are possible only through a specific application.
To do this, you can grant explicit authority to the PowerBuilder application
but not to users. The application prompts the
user for an authorization ID and password, verifies it, and then
connects to the database through a single application login ID.
Only this application login ID has authorization to update production
tables.
In this scenario, you can use the Host parameter to store
the name of the user running the application.
Examples
Example 1
To set the host name to Alan:
-
Database
profileType the following in the Workstation Name box on the Network
page in the Database Profile Setup dialog box:1Alan -
Application
Type the following in code:
1SQLCA.DbParameter="Host='Alan'"
Example 2
You can use the Host and AppName parameters together to specify
both the host name and the application name. To set the host name
to Jane and the application name to Sales:
-
Database profile
Type Jane in the Workstation Name box and Sales in the Application
Name box on the Network page in the Database Profile Setup dialog
box. -
Application
Type the following in code:
1SQLCA.DbParameter="Host='Jane',AppName='Sales'"
Example 3
The Host name in the preceding examples is hard coded. You
can get the name dynamically using the Windows GetComputerNameW function. There
is no PowerScript equivalent for this function. Here is the external function
declaration:
1 |
FUNCTION boolean GetComputerNameW(ref string cname,ref long nbuf) LIBRARY "Kernel32.dll" |
The following code in the Open event of the application uses
an external function call to get the host name and set its value
in the Host parameter. You must allocate sufficient space for the
returned host name:
1 |
string ls_compname<br>long ll_buf<br>ll_buf=25<br> <br>ls_compname=space(ll_buf)<br>GetComputerNameA(ls_compname, ll_buf) <br> <br>// Profile mysyb <br>SQLCA.DBMS="SYC Adaptive Server Enterprise" <br>SQLCA.Database="mydata" <br>SQLCA.LogPass="mylogpass" <br>SQLCA.ServerName="mysybsvr" <br>SQLCA.LogId="mylogid" <br>SQLCA.AutoCommit=False<br>SQLCA.DbParameter="Host='" + ls_compname + "'" <br> <br>Connect using SQLCA; |