public override DatabaseSchemaCollection GetDatabases() { DatabaseSchemaCollection databases = new DatabaseSchemaCollection(); using (IPooledDbConnection conn = connectionPool.Request()) { //we don't have to change it back afterwards, since the connectionpool will do this for us conn.DbConnection.ChangeDatabase("master"); using (IDbCommand command = conn.CreateCommand("select name from sysdatabases")) { try { using (command) using (IDataReader r = command.ExecuteReader()) { while (r.Read()) { DatabaseSchema db = new DatabaseSchema(this); db.Name = r.GetString(0); databases.Add(db); } r.Close(); } } catch (Exception e) { QueryService.RaiseException(e); } finally { conn.Release(); } } } return(databases); }
public override DatabaseSchemaCollection GetDatabases() { DatabaseSchemaCollection databases = new DatabaseSchemaCollection(); using (IPooledDbConnection conn = connectionPool.Request()) { using (IDbCommand command = conn.CreateCommand("SHOW DATABASES;")) { try { using (IDataReader r = command.ExecuteReader()) { while (r.Read()) { DatabaseSchema db = new DatabaseSchema(this); db.Name = r.GetString(0); databases.Add(db); } r.Close(); } } catch (Exception e) { QueryService.RaiseException(e); } finally { conn.Release(); } } } return(databases); }
public override DatabaseSchemaCollection GetDatabases () { DatabaseSchemaCollection databases = new DatabaseSchemaCollection (); using (IPooledDbConnection conn = connectionPool.Request ()) { using (IDbCommand command = conn.CreateCommand ("SHOW DATABASES;")) { try { using (IDataReader r = command.ExecuteReader()) { while (r.Read ()) { DatabaseSchema db = new DatabaseSchema (this); db.Name = r.GetString (0); databases.Add (db); } r.Close (); } } catch (Exception e) { QueryService.RaiseException (e); } finally { conn.Release (); } } } return databases; }
public void Initialize(NpgsqlSchemaProvider provider) { UserSchemaCollection users = provider.GetUsers(); DatabaseSchemaCollection databases = provider.GetDatabases(); NpgsqlEncodingCollection encodings = provider.GetEncodings(); NpgsqlTablespaceCollection tablespaces = provider.GetTablespaces(); foreach (UserSchema user in users) { ownersStore.AppendValues(user.Name, user); } foreach (DatabaseSchema db in databases) { templatesStore.AppendValues(db.Name, db); } foreach (NpgsqlEncoding enc in encodings) { StringBuilder encName = new StringBuilder(enc.Name); encName.AppendFormat(" - {0} - {1}", enc.Description, enc.Language); if (enc.Aliases != string.Empty) { encName.AppendFormat(" ({0})", enc.Aliases); } encodingsStore.AppendValues(encName.ToString(), enc); } foreach (NpgsqlTablespace ts in tablespaces) { tablespacesStore.AppendValues(ts.Name, ts); } }
protected virtual void RefreshClickedThreaded(object state) { DatabaseConnectionSettings settings = state as DatabaseConnectionSettings; DatabaseConnectionContext context = new DatabaseConnectionContext(settings); IDbFactory fac = DbFactoryService.GetDbFactory(settings.ProviderIdentifier); FakeConnectionPool pool = null; try { pool = new FakeConnectionPool(fac, fac.ConnectionProvider, context); pool.Initialize(); if (pool.HasErrors) { MessageService.ShowError(pool.Error); return; } ISchemaProvider prov = fac.CreateSchemaProvider(pool); DatabaseSchemaCollection databases = prov.GetDatabases(); DispatchService.GuiDispatch(delegate() { foreach (DatabaseSchema db in databases) { storeDatabases.AppendValues(db.Name); } }); isDatabaseListEmpty = databases.Count == 0; } catch { } finally { if (pool != null) { pool.Close(); } } if (isDatabaseListEmpty) { DispatchService.GuiDispatch(delegate() { storeDatabases.AppendValues(AddinCatalog.GetString("No databases found!")); }); } else { DispatchService.GuiDispatch(delegate() { TreeIter iter; if (storeDatabases.GetIterFirst(out iter)) { comboDatabase.SetActiveIter(iter); } }); } }
public override DatabaseSchemaCollection GetDatabases() { Console.WriteLine("GetDatabases :D"); DatabaseSchemaCollection databases = new DatabaseSchemaCollection (); using (IPooledDbConnection conn = connectionPool.Request ()) { Console.WriteLine("conn:"+conn.ToString()); MongoDbConnection connection = (MongoDbConnection) conn.DbConnection; Console.WriteLine("connection:"+connection.ToString()); foreach(string dbName in connection.getDatabases()){ DatabaseSchema db = new DatabaseSchema(this); Console.WriteLine("db add:"+dbName); db.Name = dbName; databases.Add(db); } } return databases; }
public virtual DatabaseSchemaCollection GetDatabases () { DatabaseSchemaCollection collection = new DatabaseSchemaCollection (); IPooledDbConnection conn = connectionPool.Request (); try { //restrictions: name DataTable dt = conn.GetSchema (databasesCollectionString); for (int r = 0; r < dt.Rows.Count; r++) { DataRow row = dt.Rows[r]; collection.Add (GetDatabase (row)); } } catch (Exception e) { QueryService.RaiseException (e); } conn.Release (); return collection; }
public override DatabaseSchemaCollection GetDatabases () { DatabaseSchemaCollection databases = new DatabaseSchemaCollection (); using (IPooledDbConnection conn = connectionPool.Request ()) { //we don't have to change it back afterwards, since the connectionpool will do this for us conn.DbConnection.ChangeDatabase ("master"); using (IDbCommand command = conn.CreateCommand ("select name from sysdatabases")) { try { using (command) using (IDataReader r = command.ExecuteReader()) { while (r.Read()) { DatabaseSchema db = new DatabaseSchema (this); db.Name = r.GetString (0); databases.Add (db); } r.Close (); } } catch (Exception e) { QueryService.RaiseException (e); } finally { conn.Release (); } } } return databases;