Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. using MySql.Data.MySqlClient;
  2.  
  3.  
  4. namespace MediaProviderWorker.Helpers.Database
  5. {
  6. class MysqlConnectionData
  7. {
  8. public string Server { get { return _server; }set { _server = value; } }
  9. public string Port { get { return _port; }set { _port = value; } }
  10. public string Db { get { return _db; }set { _db = value; } }
  11. public string User { get { return _user; }set { _user = value; } }
  12. public string Password { get { return _password; }set { _password = value; } }
  13. public bool Pooling { get { return _pooling; }set { _pooling = value; } }
  14.  
  15. string _server;
  16. string _port;
  17. string _db;
  18. string _user;
  19. string _password;
  20. bool _pooling;
  21.  
  22. public MysqlConnectionData() { }
  23. public MysqlConnectionData(string server, string db, string user, string password = "", string port = "3306", bool pooling = false)
  24. {
  25. _server = server;
  26. _port = port;
  27. _db = db;
  28. _user = user;
  29. _password = password;
  30. _pooling = pooling;
  31. }
  32. public override string ToString()
  33. {
  34. return string.Format("Server={0};Port={1};Database={2};User ID={3};Password={4};Pooling={5}", _server, _port, _db, _user, _password, (_pooling ? "true" : "false"));
  35. }
  36. }
  37. class MysqlProvider
  38. {
  39. MySqlConnection dbcon = null;
  40. public MysqlProvider(MysqlConnectionData ConnectionData)
  41. {
  42. dbcon = new MySqlConnection(ConnectionData.ToString());
  43. dbcon.Open();
  44. }
  45. ~MysqlProvider()
  46. {
  47. dbcon.Close();
  48. dbcon = null;
  49. }
  50.  
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement