BDD Scenarios: Automating Application Deployment

Scenario 3: Using Make and Model Values to Query a Database

Published: March 8, 2005

As before, querying a database table to retrieve the list of packages to install may be more useful than hard-coding this list in the CustomSettings.ini file. In this case, the table structure is slightly more complicated as it needs to include two identifying columns.

use [BDDAdminDB]
go

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

CREATE TABLE [dbo].[MakeModelPackages] (
	[Make] [nvarchar] (50),
	[Model] [nvarchar] (50),
	[Packages] [nvarchar] (50)
)
go

Now you can populate that table with rows for the sample Dell Latitude D600.

use [BDDAdminDB]
go

insert into MakeModelPackages (Make, Model, Packages) 
 values('Dell Computer Corporation', 'Latitude D600', 'XXX00009-Program name 9')
go 
insert into MakeModelPackages (Make, Model, Packages) 
 values('Dell Computer Corporation', 'Latitude D600', 'XXX0000A-Program name 10')
go

Fortunately, querying a database using multiple values is very simple (compared to the subsection logic described in the previous section). First, a section should be included in the Priority list.

Priority=MacAddress, DefaultGateway, MakeModelQuery, Default
CustomKeysUserData=UDShare, UDDir, UDProfiles, SLShare, OSInstall, 
Packages(*), Administrators(*), PowerUsers(*), DriverPath(*)
…

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

[MakeModelQuery]
SQLDefault= DB_MakeModelQuery

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

[DB_MakeModelQuery]
SQLServer=SERVER1
Database=BDDAdminDB
Table=MakeModelPackages
Parameters=Make, Model
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 MakeModelPackages (created above) and both the Make and Model values will be used to automatically create a query.

SELECT * FROM MakeModelPackages WHERE Make = ? AND Model = ?

The actual Make value will be substituted for the first "?" above, and the actual Model value will be substituted for the second "?" This query would return a recordset with zero or more rows; each row returned specifies one package to be added to the list of packages to be installed during the state restore phase.


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