- Feature Table
- Columns
- Remarks
- Create a database and add tables in Visual Studio
- Prerequisites
- Create a project and a local database file
- Add a data source
- View properties of the data connection
- Create tables and keys by using Table Designer
- Create the Customers table
- Create the Orders table
- Create a foreign key
- Populate the tables with data
Feature Table
The Feature Table defines the logical tree structure of features and contains the columns shown in the following table.
Column | Type | Key | Nullable |
---|---|---|---|
Feature | Identifier | Y | N |
Feature_Parent | Identifier | N | Y |
Title | Text | N | Y |
Description | Text | N | Y |
Display | Integer | N | Y |
Level | Integer | N | N |
Directory_ | Identifier | N | Y |
Attributes | Integer | N | N |
Columns
The primary key that is used to identify a specific feature record. The value in this field must not exceed a maximum length of 38 characters.
An optional key of a parent record in the same table.
The key points to the Feature column. If the parent feature is not selected, then this feature is not installed. A null value in this field indicates that this feature does not have a parent and is a root item. The Feature_Parent column must not equal the Feature column of the same record.
The maximum depth of any feature is 16. An error 2701 results if a feature that exceeds this maximum depth exists.
A short string of text that identifies a feature.
This string is listed as an item by the SelectionTree Control of the Selection Dialog.
A longer string of text that describes a feature.
This localizable string is displayed by the Text Control of the Selection Dialog.
The number in this field specifies the order in which the feature is to be displayed in the user interface.
The value also determines whether or not the feature is initially displayed expanded or collapsed. If the value is null or 0 (zero), the record is not displayed.
- If the value is odd, the feature node is expanded initially.
- If the value is even, the feature node is collapsed initially.
The initial installation level of this feature. Processing the Condition Table can modify the level value.
An install level of 0 (zero) disables the item and prevents it from being displayed. A feature with an installation level of 0 (zero) is not installed during any installation, including administrative installations. For more information, see the «Install Level» information in the Remarks section of this topic.
The Directory_ column specifies the name of a directory that can be configured by a Selection Dialog.
Because this field is a key into the Directory Table, the specified directory must be listed in the first column of the Directory Table. You must enter a Public Property in this column to make the directory configurable, and to display a Browse button on the Selection Dialog.
The remote execution option for features that are not installed and for which no feature state request is made by using any of the following properties.
Add the indicated bits to the total value of this column to include a remote execution option.
- If this field is blank, the value defaults to 0 (zero), msidbFeatureAttributesFavorLocal.
- If the feature install level is 0 (zero), or greater than or equal to the current install level, no change is made in the feature state.
Name | Decimal | Hexadecimal | Description |
---|---|---|---|
msidbFeatureAttributesFavorLocal | 0 | 0x0000 | Components of this feature that are not marked for installation from source are installed locally. A component shared by two or more features, some of which are set to msidbFeatureAttributesFavorLocal and some to msidbFeatureAttributesFavorSource, is installed locally. Components marked msidbComponentAttributesSourceOnly in the Component Table are always run from the source CD/server. The bits msidbFeatureAttributesFavorLocal and msidbFeatureAttributesFavorSource work with features not listed by the ADVERTISE Property. |
msidbFeatureAttributesFavorSource | 1 | 0x0001 | Components of this feature not marked for local installation are installed to run from the source CD-ROM or server. A component shared by two or more features, some of which are set to msidbFeatureAttributesFavorLocal and some to msidbFeatureAttributesFavorSource, is installed to run locally. Components marked msidbComponentAttributesLocalOnly in the Component Table are always installed locally. The bits msidbFeatureAttributesFavorLocal and msidbFeatureAttributesFavorSource work with features not listed by the ADVERTISE Property. |
msidbFeatureAttributesFollowParent | 2 | 0x0002 | Set this attribute and the state of the feature is the same as the state of the feature’s parent. You cannot use this option if the feature is located at the root of a feature tree. Omit this attribute and the feature state is determined according to msidbFeatureAttributesDisallowAdvertise and msidbFeatureAttributesFavorLocal and msidbFeatureAttributesFavorSource. To guarantee that the child feature’s state always follows the state of its parent, even when the child and parent are initially set to absent in the SelectionTree Control, you must include both msidbFeatureAttributesFollowParent and msidbFeatureAttributesUIDisallowAbsent in the attributes of the child feature. Note that if you set msidbFeatureAttributesFollowParent without setting msidbFeatureAttributesUIDisallowAbsent, the installer cannot force the child feature out of the absent state. In this case, the child feature matches the parent’s installation state only if the child is set to something other than absent. Set msidbFeatureAttributesFollowParent and msidbFeatureAttributesUIDisallowAbsent to ensure a child feature follows the state of the parent feature. |
msidbFeatureAttributesFavorAdvertise | 4 | 0x0004 | Set this attribute and the feature state is Advertise. If the feature is listed by the ADDDEFAULT Property this bit is ignored and the feature state is determined according to msidbFeatureAttributesFavorLocal and msidbFeatureAttributesFavorSource. Omit this attribute and the feature state is determined according to msidbFeatureAttributesDisallowAdvertise and msidbFeatureAttributesFavorLocal and msidbFeatureAttributesFavorSource. |
msidbFeatureAttributesDisallowAdvertise | 8 | 0x0008 | Note that this bit works only with features that are listed by the ADVERTISE Property. Set this attribute to prevent the feature from being advertised. Set this attribute and if the listed feature is not a parent or child, the feature is installed according to msidbFeatureAttributesFavorLocal and msidbFeatureAttributesFavorSource. Set this attribute for the parent of a listed feature and the parent is installed. Set this attribute for the child of a listed feature and the state of the child is Absent. Omit this attribute and if the listed feature is not a parent or child, the feature state is Advertise. Omit this attribute and if the listed feature is a parent or child, the state of both features is Advertise. |
msidbFeatureAttributesUIDisallowAbsent | 16 | 0x0010 | Set this attribute and the user interface does not display an option to change the feature state to Absent. Setting this attribute forces the feature to the installation state, whether or not the feature is visible in the UI. Omit this attribute and the user interface displays an option to change the feature state to Absent. Set msidbFeatureAttributesFollowParent and msidbFeatureAttributesUIDisallowAbsent to ensure a child feature follows the state of the parent feature. Setting this attribute not only affects the UI, but also forces the feature to the install state whether the feature is visible in the UI or not. |
msidbFeatureAttributesNoUnsupportedAdvertise | 32 | 0x0020 | Set this attribute and advertising is disabled for the feature if the operating system shell does not support Windows Installer descriptors. Omit this attribute and advertising is not disabled. |
Some attributes are exclusive of each other. Attempting to set these attributes together on the same feature causes the installation package to fail Package Validation.
- Do not use msidbFeatureAttributesFavorAdvertise with msidbFeatureAttributesDisallowAdvertise.
- Do not use msidbFeatureAttributesNoUnsupportedAdvertise with msidbFeatureAttributesDisallowAdvertise together.
- Do not use msidbFeatureAttributesFollowParent with msidbFeatureAttributesFavorSource.
- Note that the msidbFeatureAttributesFollowParent and msidbFeatureAttributesFavorLocal values are mutually exclusive. If the msidbFeatureAttributesFollowParent value is used, the msidbFeatureAttributesFavorLocal value is assumed to not exist.
Note that if a child feature is installed, its parent feature is also installed. If a parent feature is installed, its child feature is not necessarily installed unless its msidbFeatureAttributesFollowParent and msidbFeatureAttributesUIDisallowAbsent attributes are set. This hierarchical relationship of the installation of parent and child features is also used for the GUI installations and installations that use command-line properties.
Remarks
Several additional temporary columns are added to this table when it is loaded into memory for computations used by costing and user interface (UI) selection.
A component can be shared between two or more features or applications. If two or more features refer to the same component, then that component is selected for installation if any of the associated features are selected. This can also be the reason child features are not uninstalled when a parent feature is removed. If the child feature consists of components needed by other features or applications, the Windows Installer does not remove the child feature.
- For any installation, there is a defined install level, which is an integral value from 1 to 32,767. The initial value is determined by the INSTALLLEVEL Property, which is set in the Property Table.
- A feature is installed only if the feature level value is less than or equal to the current install level. The UI can be authored so that when the installation is initialized, the Installer allows the user to modify the install level of any feature in the Feature Table. For example, an author can define install level values that represent specific installation options, such as Custom, Typical, or Minimum, and then create a dialog box that uses SetInstallLevel ControlEvents to enable the user to select one of these states.
- Depending on the state the user selects, the dialog box sets the install level property to the corresponding value. If the author assigns Typical a level of 100 and the user selects Typical, only those features with a level of 100 or less are installed. In addition, the Custom option could lead to another dialog box that contains a SelectionTree Control. The SelectionTree Control then allows the user to individually change whether or not each feature is installed.
Create a database and add tables in Visual Studio
You can use Visual Studio to create and update a local database file in SQL Server Express LocalDB. You can also create a database by executing Transact-SQL statements in the SQL Server Object Explorer tool window in Visual Studio. In this topic, we’ll create an .mdf file and add tables and keys by using the Table Designer.
Prerequisites
To complete this walkthrough, you’ll need the .NET desktop development and Data storage and processing workloads installed in Visual Studio. To install them, open Visual Studio Installer and choose Modify (or More > Modify) next to the version of Visual Studio you want to modify.
The procedures in this article apply only to .NET Framework Windows Forms projects, not to .NET Core Windows Forms projects.
Create a project and a local database file
Create a new Windows Forms App (.NET Framework) project and name it SampleDatabaseWalkthrough.
On the menu bar, select Project > Add New Item.
In the list of item templates, scroll down and select Service-based Database.
Name the database SampleDatabase, and then click Add.
Add a data source
If the Data Sources window isn’t open, open it by pressing Shift+Alt+D or selecting View > Other Windows > Data Sources on the menu bar.
In the Data Sources window, select Add New Data Source.
The Data Source Configuration Wizard opens.
On the Choose a Data Source Type page, choose Database and then choose Next.
On the Choose a Database Model page, choose Next to accept the default (Dataset).
On the Choose Your Data Connection page, select the SampleDatabase.mdf file in the drop-down list, and then choose Next.
On the Save the Connection String to the Application Configuration File page, choose Next.
On the Choose your Database Objects page, you’ll see a message that says the database doesn’t contain any objects. Choose Finish.
View properties of the data connection
You can view the connection string for the SampleDatabase.mdf file by opening the Properties window of the data connection:
Select View > SQL Server Object Explorer to open the SQL Server Object Explorer window. Expand (localdb)\MSSQLLocalDB > Databases, and then right-click on SampleDatabase.mdf and select Properties.
Alternatively, you can select View > Server Explorer, if that window isn’t already open. Open the Properties window by expanding the Data Connections node, right-clicking on SampleDatabase.mdf, and then selecting Properties.
If you can’t expand the Data Connections node, or the SampleDatabase.mdf connection is not listed, select the Connect to Database button in the Server Explorer toolbar. In the Add Connection dialog box, make sure that Microsoft SQL Server Database File is selected under Data source, and then browse to and select the SampleDatabase.mdf file. Finish adding the connection by selecting OK.
Create tables and keys by using Table Designer
In this section, you’ll create two tables, a primary key in each table, and a few rows of sample data. You’ll also create a foreign key to specify how records in one table correspond to records in the other table.
Create the Customers table
In Server Explorer, expand the Data Connections node, and then expand the SampleDatabase.mdf node.
If you can’t expand the Data Connections node, or the SampleDatabase.mdf connection is not listed, select the Connect to Database button in the Server Explorer toolbar. In the Add Connection dialog box, make sure that Microsoft SQL Server Database File is selected under Data source, and then browse to and select the SampleDatabase.mdf file. Finish adding the connection by selecting OK.
Right-click on Tables and select Add New Table.
The Table Designer opens and shows a grid with one default row, which represents a single column in the table that you’re creating. By adding rows to the grid, you’ll add columns in the table.
In the grid, add a row for each of the following entries:
Column name | Data type | Allow nulls |
---|---|---|
CustomerID | nchar(5) | False (cleared) |
CompanyName | nvarchar(50) | False (cleared) |
ContactName | nvarchar (50) | True (selected) |
Phone | nvarchar (24) | True (selected) |
Right-click on the CustomerID row, and then select Set Primary Key.
Right-click on the default row ( Id ), and then select Delete.
Name the Customers table by updating the first line in the script pane to match the following sample:
You should see something like this:
In the upper-left corner of Table Designer, select Update.
In the Preview Database Updates dialog box, select Update Database.
The Customers table is created in the local database file.
Create the Orders table
Add another table, and then add a row for each entry in the following table:
Column name | Data type | Allow nulls |
---|---|---|
OrderID | int | False (cleared) |
CustomerID | nchar(5) | False (cleared) |
OrderDate | datetime | True (selected) |
OrderQuantity | int | True (selected) |
Set OrderID as the primary key, and then delete the default row.
Name the Orders table by updating the first line in the script pane to match the following sample:
In the upper-left corner of the Table Designer, select Update.
In the Preview Database Updates dialog box, select Update Database.
The Orders table is created in the local database file. If you expand the Tables node in Server Explorer, you see the two tables:
Create a foreign key
In the context pane on the right side of the Table Designer grid for the Orders table, right-click on Foreign Keys and select Add New Foreign Key.
In the text box that appears, replace the text ToTable with Customers.
In the T-SQL pane, update the last line to match the following sample:
In the upper-left corner of the Table Designer, select Update.
In the Preview Database Updates dialog box, select Update Database.
The foreign key is created.
Populate the tables with data
In Server Explorer or SQL Server Object Explorer, expand the node for the sample database.
Open the shortcut menu for the Tables node, select Refresh, and then expand the Tables node.
Open the shortcut menu for the Customers table, and then select Show Table Data.
Add whatever data you want for some customers.
You can specify any five characters you want as the customer IDs, but choose at least one that you can remember for use later in this procedure.
Open the shortcut menu for the Orders table, and then select Show Table Data.
Add data for some orders.
Make sure that all order IDs and order quantities are integers and that each customer ID matches a value that you specified in the CustomerID column of the Customers table.
On the menu bar, select File > Save All.