public CollectionConneccionString OpenConexionFile() { try { ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); String path = String.Format(@"C:\{0}\ConnectionString.config", name); fileMap.ExeConfigFilename = path; // @"c:\\jdlSystem\\ConnectionStrings.config"; Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); String instancia = DesEncriptar(config.AppSettings.Settings["instancia"].Value); String username = DesEncriptar(config.AppSettings.Settings["username"].Value); String password = DesEncriptar(config.AppSettings.Settings["password"].Value); String database = DesEncriptar(config.AppSettings.Settings["database"].Value); CollectionConneccionString Datos = new CollectionConneccionString(); Datos.Instancia = instancia; Datos.username = username; Datos.password = password; Datos.database = database; return(Datos); } catch (Exception ex) { throw new Exception(String.Format("{0}.openConexionFile: {1}", core, ex)); } }
public String ConnectionStrings() { try { CollectionConneccionString Values = OpenConexionFile(); String ConnectionString = String.Format("server={0} ; database={1}; User Id={2};Password = {3}; ", Values.Instancia, Values.database, Values.username, Values.password); return(ConnectionString); } catch (Exception ex) { throw new Exception(String.Format("{0}.ConnectionStrings: {1}", core, ex)); } }