0
Answer

asp.net C# using my sql i cont able to display the image

Ask a question
thiru e

thiru e

11y
1.2k
1
hi
 
i save the image using fileupload in mysql database but i cont able to retrive and display the image pls give me the solution
 public RegistrationDA()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public static void AddRegistration(string Uid, string Pwd, string SQt, string Ans, string dscode, string SName, string Add1, string Add2, string City, string State,
        string Pincode, string Phone,  string Mobile, string web, string Iso, string IsoYr, string AppNo, string Sid,string Email, byte[] img)
    {
        try
        {         
             MySqlConnection Con = null;   
             Con = new MySqlConnection("Server=localhost;Database=smartschool;Uid=root;Pwd=root;");
             Con.Open();

             string query = "Insert into tblschoolprofile(userid,password,secretquestion,answer,dscode,schoolname,address1,address2,city,state,pincode,phone,mobile,website,isocertified,isocertifiedyr,modeofeducation,applicationnoformat,schoolid,schoollogo) values('" + Uid + "','" + Pwd + "','" + SQt + "','" + Ans + "','" + dscode + "','" + SName + "','" + Add1 + "','" + Add2 + "','" + City + "','" + State + "','" + Pincode + "','" + Phone + "','" + Mobile + "','" + web + "','" + Iso + "','" + IsoYr + "','" + AppNo + "','" + Sid + "','" + Email + "','"+ img+"')";
            


            MySqlCommand cmd = new MySqlCommand(query,Con);
            cmd.CommandText = "select img from SmartSchool where Sid=''";
         
          
           
            cmd.ExecuteNonQuery();
          

        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
  
      
        public void ProcessRequest(HttpContext context)
{


    System.Data.Odbc.OdbcConnection con = new System.Data.Odbc.OdbcConnection();
    con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["sis"].ConnectionString;


    con.Open();
    System.Data.Odbc.OdbcCommand cmd = con.CreateCommand();
    cmd.CommandText = "SELECT img FROM SmartSchool WHERE =''";


    byte[] buf = (byte[])cmd.ExecuteScalar();


    context.Response.Clear();
    context.Response.OutputStream.Write(buf, 0, buf.Length);
    context.Response.ContentType = "image/jpeg";
    context.Response.BinaryWrite(buf);
}
    }
   
   
}