Guest User

Untitled

a guest
Jan 4th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. public SqlConnection GetSqlConn(DbCredentials d)
  2. {
  3. try
  4. {
  5.  
  6. dbconn = new SqlConnection();
  7. string str = @"server=" + d.server + "; user=" + d.user + "; password=" + d.password + "; database=" + d.dbName + "; Integrated Security = True; Connect Timeout=" + 7;
  8. dbconn.ConnectionString = str;
  9.  
  10. dbconn.Open();
  11.  
  12. }
  13. catch (Exception ex)
  14. {
  15. return null;
  16.  
  17. }
  18. return dbconn;
  19. }
  20.  
  21.  
  22. public class DbCredentials
  23. {
  24. public string server { get; set; }
  25. public string user { get; set; }
  26. public string password { get; set; }
  27. public string dbName { get; set; }
  28.  
  29.  
  30. }
Add Comment
Please, Sign In to add comment