/// <summary> /// /// </summary> /// <returns></returns> private ServerInstance[] LocalReadServerInstances() { List <ServerInstance> lst = new List <ServerInstance>(); MattimonSQLite.SQLiteClientDatabase db = GetLocalDatabase(); db.CreateConnectionStringTable(); DataTable dt = (DataTable)db.SelectConnectionStrings(); if (dt == null) { return(null); } foreach (DataRow row in dt.Rows) { lst.Add(new ServerInstance { ConnectionString = row["connectionstring"] as string, ServerName = row["servername"] as string, InstanceName = row["instancename"] as string, User = row["user"] as string, Monitored = Convert.ToInt16(row["monitored"]) == 1, Version = row["version"] as string }); } return(lst.ToArray()); }
/// <summary> /// /// </summary> /// <param name="result"></param> /// <returns></returns> private ServerInstance LocalWriteConnectionString(SQLServerInstanceResult result) { MattimonSQLite.SQLiteClientDatabase db = GetLocalDatabase(); db.CreateConnectionStringTable(); string servername = result.ServerName; string instancename = result.InstanceName; string connectionstring = result.ConnectionString; string username = result.Username; string version = result.Version; bool monitored = true; db.InsertConnectionString(connectionstring, servername, instancename, username, version, monitored); DataTable dt = (DataTable)db.SelectConnectionString(servername, instancename); return(new ServerInstance { ServerName = dt.Rows[0]["servername"] as string, InstanceName = dt.Rows[0]["instancename"] as string, ConnectionString = dt.Rows[0]["connectionstring"] as string, User = dt.Rows[0]["user"] as string, Clustered = result.Clustered, Monitored = Convert.ToBoolean(dt.Rows[0]["monitored"]), Version = result.Version }); }
/// <summary> /// /// </summary> /// <param name="serverName"></param> /// <param name="instanceName"></param> /// <returns></returns> private string LocalReadConnectionString(string serverName, string instanceName) { MattimonSQLite.SQLiteClientDatabase db = GetLocalDatabase(); db.CreateConnectionStringTable(); DataTable dt = (DataTable)db.SelectConnectionString(serverName, instanceName); return(dt.Rows[0]["connectionstring"] as string); }