Advertisement
Guest User

Untitled

a guest
Aug 20th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data.Odbc;
  6. using System.Configuration;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Diagnostics;
  10. using System.Data;
  11. using MySql.Data;
  12. using MySql.Data.MySqlClient;
  13. using System.IO;
  14. using System.Text;
  15. using System.Net.Mail;
  16.  
  17. /// <summary>
  18. /// Summary description for MySqlManager
  19. /// </summary>
  20. /// [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
  21. ///
  22.  
  23.  
  24. public class MySqlManager
  25. {
  26.  
  27. private static String Server = "Illusionscape.no-ip.org";
  28. private static String UserName = "Khalaila";
  29. private static String Password = "alphaSecrets";
  30. private static String DataBase = "illusion-scape";
  31. private static MySqlConnection Connection;
  32. private static String[] Emails = { "Supersecrets212@gmail.com" };
  33. /* private static String Subject = "Illusion-Scape Website Debugging";
  34. private static String Message = "Connected to MySql Succefully !";
  35. */
  36.  
  37. public static void InitiializeConnection()
  38. {
  39. try
  40. {
  41. MySqlConnectionStringBuilder ConnectionString = new MySqlConnectionStringBuilder();
  42. ConnectionString.Server = Server;
  43. ConnectionString.UserID = UserName;
  44. ConnectionString.Password = Password;
  45. ConnectionString.Database = DataBase;
  46. String Connect = ConnectionString.ToString();
  47. Debug.WriteLine("[Connection String]" + Connect);
  48. Connection = new MySqlConnection(Connect);
  49.  
  50. Connection.Open();
  51. Connection.Close();
  52.  
  53. // System.Diagnostics.Debug.WriteLine("Connected to The MySql DataBase Sucessfully !");
  54.  
  55.  
  56.  
  57. // Methods.SendSupportEmail(Message,Emails,Subject);
  58. }
  59. catch (Exception ex)
  60. {
  61. // Message = "Error Connected to Mysql !! <br><br><br> Error Message = " + ex;
  62. // Methods.SendSupportEmail(Message, Emails, Subject);
  63.  
  64. }
  65. }
  66.  
  67. //------------------------------------------------------------------------------------------------\\
  68.  
  69.  
  70. //------------------------------------------------------------------------------------------------\\
  71. public static DataTable SelectFromDB(String SqlString)
  72. {
  73. try
  74. {
  75. Debug.WriteLine("[Attempting of Executing] " + SqlString);
  76. InitiializeConnection();
  77. MySqlCommand SqlCommand = new MySqlCommand(SqlString, Connection);
  78.  
  79. Connection.Open();
  80. DataTable Dt = new DataTable();
  81. MySqlDataReader Reader = SqlCommand.ExecuteReader();
  82. Dt.Load(Reader);
  83. Connection.Close();
  84. // Debug.WriteLine("Table Selected !");
  85. // Message = "Table Selected Sucessfully !";
  86. // Methods.SendSupportEmail(Message, Emails, Subject);
  87. return Dt;
  88.  
  89. }
  90. catch (Exception Ex)
  91. {
  92. Debug.WriteLine("[Error Selecting Table] " + Ex);
  93. //Message = "Error Connected to Mysql !! <br><br><br>" + "[Error Selecteing Table] " + Ex;
  94. // Methods.SendSupportEmail(Message, Emails, Subject);
  95.  
  96.  
  97. }
  98. return null;
  99. }
  100. //------------------------------------------------------------------------------------------------\\
  101.  
  102. public static void ChangeDB(String SqlString)
  103. {
  104. Debug.WriteLine("[Attempting of Executing] " + SqlString);
  105. // SqlString = "insert into Donations (guid) values(112)";
  106. try
  107. {
  108. InitiializeConnection();
  109. MySqlCommand SqlCommand = new MySqlCommand(SqlString, Connection);
  110. Connection.Open();
  111. SqlCommand.ExecuteNonQuery();
  112. Connection.Close();
  113. Debug.WriteLine("Table Changed !");
  114. // Message = "Table Changed Sucessfully !";
  115. // Methods.SendSupportEmail(Message, Emails, Subject);
  116. }
  117. catch (Exception Ex)
  118. {
  119. Debug.WriteLine("[Error Changing Table] " + Ex);
  120. // Message = "Error Connected to Mysql !! <br><br><br>" + "[Error Changing Table] " + Ex;
  121. // Methods.SendSupportEmail(Message, Emails, Subject);
  122.  
  123. }
  124. }
  125. //------------------------------------------------------------------------------------------------\\
  126. public MySqlManager()
  127. {
  128. //
  129. // TODO: Add constructor logic here
  130. //
  131.  
  132.  
  133. }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement