/// <summary>Creates a connection on the browser</summary>
 public void CreateConnection()
 {
     ConnectDialog cd = new ConnectDialog();
     cd.ShowDialog();
     if (cd.DataAccess != null)
     {
         if (!this._tree.Cache.ContainsKey("ROOT") || this._tree.Cache["ROOT"].FirstOrDefault(d => d.Name == cd.DataAccess.DataSource) == null)
         {
             this.AddServer(cd.DataAccess);
             this._activeConnection = cd.DataAccess;
         }
         else
         {
             MessageBox.Show("This server is already added!");
         }
     }
 }
Esempio n. 2
0
        /// <summary>Initialize the query</summary>
        /// <param name="OpenQuery">Whether or not to open an existing query</param>
        /// <returns>String representing the initial text of the query</returns>
        public string InitQuery(bool OpenQuery)
        {
            string queryText = string.Empty;

            if (OpenQuery)
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Multiselect = false;
                open.Filter = FILE_TYPES;

                if (open.ShowDialog() == DialogResult.OK)
                {
                    this._fileName = open.FileName;
                    this._safeFileName = open.SafeFileName;
                    FileStream query = new FileStream(this._fileName, FileMode.Open, FileAccess.Read);
                    StreamReader reader = new StreamReader(query);
                    queryText = reader.ReadToEnd();
                    reader.Close();
                    reader.Dispose();
                    query.Close();
                    query.Dispose();

                    this._isSaved = true;
                }
            }

            if (this._dab == null)
            {
                ConnectDialog cd = new ConnectDialog();
                cd.ShowDialog();
                this._dab = cd.DataAccess;
            }

            this._databases = this._dab.GetDatabases();

            return queryText;
        }