Exemple #1
0
        private bool InitDatabaseList(SqlAccessor sqlAccessor)
        {
            cmbDataBase.Items.Clear();
            if (!sqlAccessor.TryConnect())
            {
                return(false);
            }
            List <string> dbs = sqlAccessor.GetDatabases();

            cmbDataBase.Items.AddRange(dbs.ToArray());
            return(true);
        }
Exemple #2
0
        private async void InitDatabaseListAsync(SqlAccessor sqlAccessor)
        {
            cmbDataBase.Items.Clear();
            List <string> dbs = await Task.Run(() =>
            {
                if (!sqlAccessor.TryConnect())
                {
                    return(null);
                }
                return(sqlAccessor.GetDatabases());
            });

            if (dbs == null)
            {
                return;
            }
            cmbDataBase.Items.AddRange(dbs.ToArray());
        }