none
how to check the database if I insert a picture.

Toutes les réponses

  • how to check the database column with Slika2 if I insert a picture.


    To datebse insight picture of use
    <% @ WebHandler Language = "C #" Class = "Handler"%>

    using System;
    using System.Web;
    using System.Configuration;
    using System.Data.SqlClient;

    public class Handler: IHttpHandler {

         public void ProcessRequest (HttpContext context)
         {

             SqlConnection con = new SqlConnection (@ "Data Source = RU-PC \ SQLEXPRESS; Initial Catalog = Proizvodi; Integrated Security = True");
             / / Create SQL Command

            
             SqlCommand cmd = new SqlCommand ();
             cmd.CommandText = "SELECT Slika5 FROM Proizvodi" +
                               "WHERE Pro_ID = @ ID";
             cmd.CommandType = System.Data.CommandType.Text;
             cmd.Connection = con;

             SqlParameter ImageID = new SqlParameter
                                 ("@ ID", System.Data.SqlDbType.Int);
             ImageID.Value = context.Request.QueryString ["ID"];;
             cmd.Parameters.Add (ImageID);
             con.Open ();

             SqlDataReader dReader = cmd.ExecuteReader ();
             dReader.Read ();
             context.Response.BinaryWrite ((byte []) dReader ["Slika5"]);
             dReader.Close ();
             con.Close ();
         }
         public bool IsReusable
         {
             get
             {
                 return false;
             }
         }
    }
    mercredi 1 février 2012 00:07
  • Add an picturebox control in your application and use the below code

    using (MemoryStream ms = new MemoryStream((byte[])dReader["Slika5"]))
                {
                    ms.Position = 0;
                    ms.Seek(0, SeekOrigin.Begin);
                    pictureBox1.Image = System.Drawing.Image.FromStream(ms);
                    ms.Flush();
                    ms.Close();
                }
    jeudi 2 février 2012 09:19