1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| private void BindDataGrid(int user)
{
MySqlConnection Connection = new MySqlConnection();
Connection.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConnStr"].ConnectionString;
try
{
// Ici, on ouvre la connexion au serveur
Connection.Open();
}
catch (Exception excp)
{
Exception myExcp = new Exception("Could not Open. Error: " +
excp.Message, excp);
throw (myExcp);
}
// string MySQLCmd = string.Format("SELECT e.DateEvent,a.IdTag,b.State,d.Nom,d.Description,d.Diametre,d.Longueur,b.IdNum,c.RefProduit,d.Reference,e.IdNum,e.IdUser FROM tageventtable a,statetable b,produittable c,producttable d,readereventtable e WHERE a.IdState<>2 AND a.IdState=b.IdNum AND a.IdEvent=e.IdNum AND a.IdTag=c.TagId AND e.IdUser={0} AND c.RefProduit=d.Reference ORDER BY e.DateEvent DESC LIMIT 20", user);
string MySQLCmd = string.Format("SELECT b.DateEvent,a.IdTag,d.Nom,d.Description,d.Diametre,d.Longueur,e.State FROM tageventtable a JOIN readereventtable b ON a.IdEvent=b.IdNum JOIN produittable c ON a.IdTag=c.TagId JOIN producttable d ON d.Reference=c.RefProduit JOIN statetable e ON e.IdNum=a.IdState WHERE b.IdUser={0} AND a.IdState<>2 ORDER BY b.DateEvent DESC LIMIT 20;", user);
MySqlCommand readEvent = new MySqlCommand(MySQLCmd, Connection);
try
{
DataGrid1.DataSource = readEvent.ExecuteReader();
DataGrid1.DataBind();
readEvent.Dispose();
}
catch (Exception ex)
{
Response.Write("An error occured: " + ex.Message);
}
Connection.Close();
} |