public void getProductsbyStore(string storeID,string clientID,string frm) { try { //0 - exception //1 - success //2 - if no storeID detected - PageNotFound //3- no stores detected MySQLBusinessLogic bl = new MySQLBusinessLogic(); DataTable dt = new DataTable(); int sID; if (storeID == null || storeID == "") Clients.Client(clientID).storeProducts("2"); else { if (frm == "1") { sID = Convert.ToInt32(storeID); dt = bl.GetProductsbyStores(sID); } else if (frm == "2") { dt = bl.GetAllProducts(); } if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { DataTable temp = new DataTable(); for (int c = 0; c < dt.Columns.Count; c++) { DataColumn dc = new DataColumn(); dc.ColumnName = dt.Columns[c].ToString(); if (dc.ColumnName == "ProductImage") { dc.DataType = typeof(string); } else dc.DataType = dt.Columns[c].DataType; temp.Columns.Add(dc); } //temp.Rows[i].ItemArray = dt.Rows[i].ItemArray; temp.ImportRow(dt.Rows[i]); string ImageUrl = "NoImage"; if (dt.Rows[i]["ProductImage"].GetType().Name != "DBNull") { byte[] bytes = (Byte[])dt.Rows[i]["ProductImage"]; string base64String = Convert.ToBase64String(bytes, 0, bytes.Length); ImageUrl = "data:image/png;base64," + base64String; } temp.Rows[0]["ProductImage"] = ImageUrl; string json = ConvertDataTabletoString(temp); Clients.Client(clientID).storeProducts("1", json); } } else { Clients.Client(clientID).storeProducts("3"); } } } catch (Exception ex) { Clients.Client(clientID).storeProducts("0"); } }