Initial commit
This commit is contained in:
36
C#/WebApplication/MySQL.cs
Normal file
36
C#/WebApplication/MySQL.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using MySqlConnector;
|
||||
|
||||
namespace WebApplication {
|
||||
public class MySQL {
|
||||
private const string Server = "leon-hoppe.de";
|
||||
private const string Database = "WebApplication";
|
||||
private const string Username = "WebApplication";
|
||||
private const string Password = "/q/cIGlBK.FgNphs";
|
||||
|
||||
private static MySqlConnection _con;
|
||||
private static MySqlCommand _command;
|
||||
|
||||
public static void Connect() {
|
||||
var builder = new MySqlConnectionStringBuilder { Server = Server, Database = Database, UserID = Username, Password = Password };
|
||||
_con = new MySqlConnection(builder.ConnectionString);
|
||||
_con.Open();
|
||||
_command = _con.CreateCommand();
|
||||
Console.WriteLine("MySQL connected Successfully");
|
||||
}
|
||||
|
||||
public static bool IsConnected() {
|
||||
return _con != null;
|
||||
}
|
||||
|
||||
public static void Insert(string qry) {
|
||||
_command.CommandText = qry;
|
||||
_command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public static MySqlDataReader GetData(string qry) {
|
||||
_command.CommandText = qry;
|
||||
return _command.ExecuteReader();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user