public SqlAnywhereConnectionManager(string userId, string password) { _currentDatabase = null; UserId = userId; Password = password; Databases = new List<SqlAnywhereDatabase>(); }
public bool ConnectToDatabase(string databaseName) { var database = SqlAnywhereDatabase.GetDatabase(databaseName, UserId, Password); if (database != null) { Databases.Add(database); _currentDatabase = database; return true; } return false; }
public bool DisconnectDatabase(string dataBaseName) { var databaseToDisconnect = Databases.First(database => database.Name == dataBaseName); if(databaseToDisconnect != null) { databaseToDisconnect.Disconnect(); Databases.Remove(databaseToDisconnect); _currentDatabase = null; return true; } return false; }
public static SqlAnywhereDatabase GetDatabase(string dataBaseName, string userId, string password) { var dataBase = new SqlAnywhereDatabase(); dataBase.Name = dataBaseName; dataBase.SetConnectionString(dataBaseName, userId, password); try { dataBase.Connect(); return dataBase; } catch (Exception) { return null; } }