Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Data.Odbc;
- using System.Configuration;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Diagnostics;
- using System.Data;
- using MySql.Data;
- using MySql.Data.MySqlClient;
- using System.IO;
- using System.Text;
- using System.Net.Mail;
- /// <summary>
- /// Summary description for MySqlManager
- /// </summary>
- /// [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
- ///
- public class MySqlManager
- {
- private static String Server = "Illusionscape.no-ip.org";
- private static String UserName = "Khalaila";
- private static String Password = "alphaSecrets";
- private static String DataBase = "illusion-scape";
- private static MySqlConnection Connection;
- private static String[] Emails = { "Supersecrets212@gmail.com" };
- /* private static String Subject = "Illusion-Scape Website Debugging";
- private static String Message = "Connected to MySql Succefully !";
- */
- public static void InitiializeConnection()
- {
- try
- {
- MySqlConnectionStringBuilder ConnectionString = new MySqlConnectionStringBuilder();
- ConnectionString.Server = Server;
- ConnectionString.UserID = UserName;
- ConnectionString.Password = Password;
- ConnectionString.Database = DataBase;
- String Connect = ConnectionString.ToString();
- Debug.WriteLine("[Connection String]" + Connect);
- Connection = new MySqlConnection(Connect);
- Connection.Open();
- Connection.Close();
- // System.Diagnostics.Debug.WriteLine("Connected to The MySql DataBase Sucessfully !");
- // Methods.SendSupportEmail(Message,Emails,Subject);
- }
- catch (Exception ex)
- {
- // Message = "Error Connected to Mysql !! <br><br><br> Error Message = " + ex;
- // Methods.SendSupportEmail(Message, Emails, Subject);
- }
- }
- //------------------------------------------------------------------------------------------------\\
- //------------------------------------------------------------------------------------------------\\
- public static DataTable SelectFromDB(String SqlString)
- {
- try
- {
- Debug.WriteLine("[Attempting of Executing] " + SqlString);
- InitiializeConnection();
- MySqlCommand SqlCommand = new MySqlCommand(SqlString, Connection);
- Connection.Open();
- DataTable Dt = new DataTable();
- MySqlDataReader Reader = SqlCommand.ExecuteReader();
- Dt.Load(Reader);
- Connection.Close();
- // Debug.WriteLine("Table Selected !");
- // Message = "Table Selected Sucessfully !";
- // Methods.SendSupportEmail(Message, Emails, Subject);
- return Dt;
- }
- catch (Exception Ex)
- {
- Debug.WriteLine("[Error Selecting Table] " + Ex);
- //Message = "Error Connected to Mysql !! <br><br><br>" + "[Error Selecteing Table] " + Ex;
- // Methods.SendSupportEmail(Message, Emails, Subject);
- }
- return null;
- }
- //------------------------------------------------------------------------------------------------\\
- public static void ChangeDB(String SqlString)
- {
- Debug.WriteLine("[Attempting of Executing] " + SqlString);
- // SqlString = "insert into Donations (guid) values(112)";
- try
- {
- InitiializeConnection();
- MySqlCommand SqlCommand = new MySqlCommand(SqlString, Connection);
- Connection.Open();
- SqlCommand.ExecuteNonQuery();
- Connection.Close();
- Debug.WriteLine("Table Changed !");
- // Message = "Table Changed Sucessfully !";
- // Methods.SendSupportEmail(Message, Emails, Subject);
- }
- catch (Exception Ex)
- {
- Debug.WriteLine("[Error Changing Table] " + Ex);
- // Message = "Error Connected to Mysql !! <br><br><br>" + "[Error Changing Table] " + Ex;
- // Methods.SendSupportEmail(Message, Emails, Subject);
- }
- }
- //------------------------------------------------------------------------------------------------\\
- public MySqlManager()
- {
- //
- // TODO: Add constructor logic here
- //
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement