BDD Scenarios: Automating Application Deployment

Scenario 4: Using MAC Address Values to Query a Database

Published: March 8, 2005

As in the previous scenarios, querying a database to retrieve a list of computer-specific packages is a three-step process:

Define a table to hold the computer-specific information.

Populate the table with the required computer-specific records.

Modify the CustomSettings.ini file to cause the database table to be queried.

In this scenario, the following table can be created in the BDDAdminDB database.

use [BDDAdminDB]
go

if exists (select * from dbo.sysobjects where id = 
 object_id(N'[dbo].[ComputerPackages]') and 
 OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[ComputerPackages]
go

CREATE TABLE [dbo].[ComputerPackages] (
	[MacAddress] [nvarchar] (50),
	[Packages] [nvarchar] (50)
)
go

Now you can populate that table with rows for each role. Continuing with the example above, you could insert two rows, one for each of the packages that need to be installed.

use [BDDAdminDB]
go

insert into ComputerPackages (MacAddress, Packages) 
 values('00:03:FF:CB:4E:C2', 'XXX0000B-Program name 11')
go 
insert into ComputerPackages (MacAddress, Packages) 
 values('00:03:FF:CB:4E:C2', 'XXX0000C-Program name 12')
go

Next, the CustomSettings.ini file must be configured to query this database table by specifying the name of a section (in the Priority list) that points to the database information.

[Settings]
…
Priority=MacAddress, DefaultGateway, ComputerQuery, Default
…

This new RoleQuery section must then specify the name of a database section.

[ComputerQuery]
SQLDefault= DB_ComputerQuery

Then that section specifies the database connection information and query details.

[DB_ComputerQuery]
SQLServer=SERVER1
Database=BDDAdminDB
Table=ComputerPackages
Parameters=MacAddress
SQLShare=Logs

In this case, the BDDAdminDB database on the computer running SQL Server named SERVER1 will be queried. This database contains a table named ComputerPackages (created above) and the MacAddress values will be used to automatically create a query.

SELECT * FROM ComputerPackages WHERE MacAddress IN (?,?,?)

The actual MacAddress values (in this case, assuming there are three values—one for each of three network cards) will be substituted for the "?" values above. This query would return a recordset with two rows; each of which specifies one package to be added to the list of packages to be installed during the state restore phase.


Top of pageTop of pagePrevious17 of 20Next
**
In This Article
**