public static List <string> GetListConnection(string AppName, string ServerName, bool IntegratedSecurity, string UserName, string Password) { List <string> RetVal = new List <string>(); try { DataPersistance TmpCn = new SqlServerPersistance(ServerName, "master", false, string.Empty, IntegratedSecurity, UserName, Password); DataTable dt = TmpCn.OpenDataTable( "select name From sysdatabases where name not in ('master','model','msdb','tempdb')"); foreach (DataRow dr in dt.Rows) { string TmpStr = (string)dr[0]; try { if (TmpCn.Find.IsExists(string.Concat("select VarName FROM [", TmpStr, "].dbo._System_AppVariable WHERE ModuleName='System' AND VarName='AppName' AND VarValue='", AppName, "'"))) { RetVal.Add(TmpStr); } } catch { } } } catch { } return(RetVal); }
public SqlServerPersistance(SqlServerPersistance Dp) : base(Dp.ConnectionString, Dp.AutoCreateDb, Dp.FolderLocation) { string TmpStr = BaseUtility .GetValueFromConnectionString( ConnectionString, "Integrated Security"); _IntegratedSecurity = string.Compare(TmpStr, "SSPI", true) == 0 || string.Compare(TmpStr, "True", true) == 0; if (!_IntegratedSecurity) { _UserName = BaseUtility.GetValueFromConnectionString( ConnectionString, "User ID"); _Password = BaseUtility.GetValueFromConnectionString( ConnectionString, "Password"); } _ServerName = BaseUtility.GetValueFromConnectionString( ConnectionString, "Server"); _DatabaseName = BaseUtility.GetValueFromConnectionString( ConnectionString, "Initial Catalog"); Connection = CreateConnection(); ListTable = Dp.ListTable; }