Advertisement
Guest User

asdas

a guest
Dec 6th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Linq;
  5. using System.Web;
  6.  
  7. namespace MVC5App.Models
  8. {
  9.   public class Helpers
  10.   {
  11.     public static string GetRDSConnectionString()
  12.     {
  13.       var appConfig = ConfigurationManager.AppSettings;
  14.  
  15.       string dbname = appConfig["RDS_DB_NAME"];
  16.  
  17.       if (string.IsNullOrEmpty(dbname)) return null;
  18.  
  19.       string username = appConfig["RDS_USERNAME"];
  20.       string password = appConfig["RDS_PASSWORD"];
  21.       string hostname = appConfig["RDS_HOSTNAME"];
  22.       string port = appConfig["RDS_PORT"];
  23.  
  24.       return "Data Source=" + hostname + ";Initial Catalog=" + dbname + ";User ID=" + username + ";Password=" + password + ";";
  25.     }
  26.   }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement