public async Task <TreeNode[]> GetDBNames() { var db = await Task.Run(() => GetListNames.GetDBNames()); var tree = new TreeNode[db.Count]; for (int i = 0; i < tree.Length; i++) { tree[i] = new TreeNode(db[i], 0, 1, await Task.Run(() => GetTableNames(db[i]))) { Tag = "DB" }; if (tree[i].GetNodeCount(false) == 0) { tree[i].ForeColor = System.Drawing.Color.Gray; tree[i].ImageIndex = 4; } } return(tree); }
internal static bool CreateDB(string dbName) { foreach (var db in GetListNames.GetDBNames()) { if (db == dbName) { return(false); } } CloseConnections(); using (SqlConnection connection = new SqlConnection(_connectionStr.ToString())) { IDbCommand command = new SqlCommand($"Create DataBase [{dbName}]"); command.Connection = connection; connection.Open(); command.ExecuteNonQuery(); CloseConnection(connection); } return(true); }