public ViewDesignerDoc(int itemId, DataViewHierarchyAccessor accessor, string viewName)
        {
            _accessor   = accessor;
            _connection = accessor.Connection;
            _itemId     = itemId;
            InitializeComponent();

            _init = true;
            try
            {
                _typeQB = SQLiteDataAdapterToolboxItem._vsdesigner.GetType("Microsoft.VSDesigner.Data.Design.QueryBuilderControl");

                if (_typeQB != null)
                {
                    _queryDesigner = Activator.CreateInstance(_typeQB) as UserControl;
                    _typeQB.InvokeMember("Provider", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { "System.Data.SQLite" });
                    _typeQB.InvokeMember("ConnectionString", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { _connection.ConnectionSupport.ConnectionString });
                    _typeQB.InvokeMember("EnableMorphing", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { false });
                    Controls.Add(_queryDesigner);
                    _queryDesigner.Dock    = DockStyle.Fill;
                    _queryDesigner.Visible = true;
                }

                StringBuilder tables = new StringBuilder();

                using (DataReader reader = _connection.Command.Execute("SELECT * FROM sqlite_master", 1, null, 30))
                {
                    while (reader.Read())
                    {
                        tables.Append(reader.GetItem(2).ToString());
                        tables.Append(",");
                    }
                }

                int n = 1;

                if (String.IsNullOrEmpty(viewName))
                {
                    string alltables = tables.ToString();

                    do
                    {
                        viewName = String.Format(CultureInfo.InvariantCulture, "View{0}", n);
                        n++;
                    } while (alltables.IndexOf(viewName + ",", StringComparison.OrdinalIgnoreCase) > -1 || _editingTables.ContainsValue(viewName));

                    _editingTables.Add(GetHashCode(), viewName);
                }
                _view = new SQLite.Designer.Design.View(viewName, _connection.ConnectionSupport.ProviderObject as DbConnection, this);
            }
            finally
            {
                _init = false;
            }
        }
    public ViewDesignerDoc(int itemId, DataViewHierarchyAccessor accessor, string viewName)
    {
      _accessor = accessor;
      _connection = accessor.Connection;
      _itemId = itemId;
      InitializeComponent();

      _init = true;
      try
      {
        _typeQB = SQLiteDataAdapterToolboxItem._vsdesigner.GetType("Microsoft.VSDesigner.Data.Design.QueryBuilderControl");

        if (_typeQB != null)
        {
          _queryDesigner = Activator.CreateInstance(_typeQB) as UserControl;
          _typeQB.InvokeMember("Provider", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { SQLiteOptions.GetProviderName() });
          _typeQB.InvokeMember("ConnectionString", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { _connection.ConnectionSupport.ConnectionString });
          _typeQB.InvokeMember("EnableMorphing", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { false });
          Controls.Add(_queryDesigner);
          _queryDesigner.Dock = DockStyle.Fill;
          _queryDesigner.Visible = true;
        }

        StringBuilder tables = new StringBuilder();

        using (DataReader reader = _connection.Command.Execute("SELECT * FROM sqlite_master", 1, null, 30))
        {
          while (reader.Read())
          {
            tables.Append(reader.GetItem(2).ToString());
            tables.Append(",");
          }
        }

        int n = 1;

        if (String.IsNullOrEmpty(viewName))
        {
          string alltables = tables.ToString();

          do
          {
            viewName = String.Format(CultureInfo.InvariantCulture, "View{0}", n);
            n++;
          } while (alltables.IndexOf(viewName + ",", StringComparison.OrdinalIgnoreCase) > -1 || _editingTables.ContainsValue(viewName));

          _editingTables.Add(GetHashCode(), viewName);
        }
        _view = new SQLite.Designer.Design.View(viewName, _connection.ConnectionSupport.ProviderObject as DbConnection, this);
      }
      finally
      {
        _init = false;
      }
    }
 internal ViewHolder(SQLite.Designer.Design.View parent)
 {
     _triggers = parent.Triggers as List <ViewTrigger>;
 }