class MySQL
{
#region MySQL Dichiarazioni
static ADODB.Connection MySQL_Conn = new ADODB.Connection();
static ADODB.Recordset MySQL_rs = new ADODB.Recordset();
#endregion
#region MySQL Connection Information
public string MySQL_IP = "localhost";
public int MySQL_Port = 3306;
public string MySQL_DB = "nomedatabase";
public string MySQL_Username = "username";
public string MySQL_Password = "password";
#endregion
public MySQL()
{
Connect();
}
/* Connessione con il Database MySQL */
private void Connect()
{
try
{
MySQL_Conn.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};Server=" + MySQL_IP + ";Port=" + MySQL_Port + ";Database=" + MySQL_DB + ";User=" + MySQL_Username + ";Password=" + MySQL_Password + ";Option=3;";
MySQL_Conn.Open(null, null, null, 0);
MySQL_rs.ActiveConnection = MySQL_Conn;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
internal Boolean CheckExists(string TheQuery)
{
MySQL_rs.Open(TheQuery, null, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockOptimistic, -1);
if (MySQL_rs.EOF == false)
return true;
else
return false;
}
}