Dear Code Masters,
Good day to you all, I have a web page that have a textbox and a button for searching student record.
if the student id is entered in the textbox and the button is clicked the c# code behind search and displayed the record if found. The database structure is shown below :
once we search the record "cis/001" i expect the name, RegNo and the image to displayed on my development machine it worked fine, but after deploying both the database and the files to the cloud it is not working.
i have tried using this code:
- Image1.ImageUrl = "ImageHandler.ashx?id=" + "CIS/001"
- DT = ConnectAll.GetTableID(id);
- foreach (DataRow r in DT.Rows)
- {
- Byte[] bytes = (Byte[])r["picture"];
- string Base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
- Image1.ImageUrl = "data:image/png;base64," + Base64String;
- }
;
the imageHandler page is a GenericHandler which have the following code:
- public void ProcessRequest (HttpContext context) {
-
-
- try
- {
- string id = context.Request.QueryString["id"].ToString();
- using (SqlConnection cn = new SqlConnection(ConnectAll.ConnectMe()))
- {
- cn.Open();
- string SQL = "Select * from tbl_studReg where id ="+id;
- SqlCommand cmd = new SqlCommand(SQL, cn);
-
-
- SqlDataReader r = cmd.ExecuteReader();
- while (r.Read())
- {
- context.Response.BinaryWrite((byte[])r["picture"]);
- }
- }
- }
- catch (Exception ex)
- {
-
- }
- }
these didn't work, i also tried the following code too
- DT = ConnectAll.GetTableID(id);
- foreach (DataRow r in DT.Rows)
- {
- Byte[] bytes = (Byte[])r["picture"];
- string Base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
- Image1.ImageUrl = "data:image/png;base64," + Base64String;
- }
above i have a class that return a datatable (DT)
all these did wor either but on my machine both method work fine displaying the image and the other records. Please can anyone help me?
thank you all