Official exmaple:
http://dev.mysql.com/doc/refman/5.1/en/connector-net-tutorials-entity-framework-winform-data-source.html
Another one:
http://www.codeproject.com/Tips/426790/Using-MySQL-with-Entity-Framework
Tuesday, July 30, 2013
How to get Open ticket number for one queue in OTRS MySQL database by .Net ?
using MySql.Data.MySqlClient; public class MySQLDBConnector { private MySqlConnection connection; private string server; private string database; private string uid; private string password; //Constructor public MySQLDBConnector() { Initialize(); } //Initialize values private void Initialize() { server = "10.0.x.x"; // "otrs.chatham.teksavvy.ca"; database = "otrs"; uid = "xxxx"; password = "xxxx"; string connectionString = "SERVER=" + server + ";Port=3306;" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";"; connection = new MySqlConnection(connectionString); } //open connection to database public bool OpenConnection() { try { connection.Open(); return true; } catch (MySqlException ex) { switch (ex.Number) { } return false; } } public int Count() { string query = @"select count(*) from ticket inner join queue on ticket.queue_id= queue.id inner join ticket_state on ticket_state.id = ticket.ticket_state_id where queue.name ='Junk' and ticket.ticket_state_id = 4"; ; int Count = -1; //Open Connection if (this.OpenConnection() == true) { //Create Mysql Command MySqlCommand cmd = new MySqlCommand(query, connection); //ExecuteScalar will return one value Count = int.Parse(cmd.ExecuteScalar() + ""); //close Connection connection.Close(); return Count; } else { return Count; } } }
Subscribe to:
Posts (Atom)