How to remove tables from the Data Wizard
Hi,
I have some code that only includes some tables for the data connection. But, as soon as I go into the Data Wizard to create a new DataSource, all of the tables appear, instead of only the tables that I want the user to see.
How can I limit which tables that the user can see in the Data Wizard and the Query Builder?
Daniel Rail
I have some code that only includes some tables for the data connection. But, as soon as I go into the Data Wizard to create a new DataSource, all of the tables appear, instead of only the tables that I want the user to see.
How can I limit which tables that the user can see in the Data Wizard and the Query Builder?
Daniel Rail
Comments
You may use the Config.DesignerSettings.FilterConnectionTables event to filter unnecessary tables. Here is the example in the Class Reference:
/// <summary>
/// Occurs when getting available table names from the connection.
/// </summary>
/// <remarks>
/// Use this handler to filter the list of tables returned by the connection object.
/// </remarks>
/// <example>
/// This example demonstrates how to hide the table with "Table 1" name from the Data Wizard.
/// <code>
/// Config.DesignerSettings.FilterConnectionTables += DesignerSettings_FilterConnectionTables;
///
/// private void DesignerSettings_FilterConnectionTables(object sender, FilterConnectionTablesEventArgs e)
/// {
/// if (e.TableName == "Table 1")
/// e.Skip = true;
/// }
/// </code>
/// </example>
Thanks a lot. It works. Maybe, you can add it to the Programmer's Manual, because that was the first obvious place that I look at, as a quick reference.
Daniel