C# Archives - Tech Insights https://reactconf.org/category/how-to-retrieve-image-from-database-using-c/ Unveiling Tomorrow's Tech Today, Where Innovation Meets Insight Sun, 31 Aug 2014 17:51:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 https://i0.wp.com/reactconf.org/wp-content/uploads/2023/11/cropped-reactconf.png?fit=32%2C32&ssl=1 C# Archives - Tech Insights https://reactconf.org/category/how-to-retrieve-image-from-database-using-c/ 32 32 230003556 How to retrieve image from database using C# https://reactconf.org/how-to-retrieve-image-from-database/ https://reactconf.org/how-to-retrieve-image-from-database/#respond Sun, 31 Aug 2014 17:51:00 +0000 http://www.sqlneed.com/2014/08/31/how-to-retrieve-image-from-database-using-c/ This C# program explain how you can retrieve images from SQL Server Database. First you need to Create New Project and give the Name of the project is RetrieveImageFromDataBase Add …

The post How to retrieve image from database using C# appeared first on Tech Insights.

]]>
This C# program explain how you can retrieve images from SQL Server Database. First you need to Create New Project and give the Name of the project is RetrieveImageFromDataBase Add the label, TextBox, command button and picture box control and copy this code and paste. So please change the data source name, database name and Table name.
Please Give the Comments.
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
usingSystem.IO;
namespaceRetrieveImageFromDataBase
{
    public partial class Form1 : Form
    {
        publicForm1()
        {
            InitializeComponent();
        }
        privatevoid button1_Click(objectsender, EventArgs e)
        {
            SqlConnectioncon = new SqlConnection(“Data Source=localhost;Initial Catalog=DataBaseName;Integrated Security=True”);
           
            con.Open();
            stringsql = “Select Photo from Employee where CustId=” + textBox1.Text +“”;
            SqlDataAdapterdadata = new SqlDataAdapter(sql,con);
            DataSetdsdata = new DataSet(“Employee”);
            dadata.Fill(dsdata, “Employee”);
            intcnt = dsdata.Tables[0].Rows.Count;
            if(cnt > 0)
            {
                byte[] Imgdata = (byte[])dsdata.Tables[0].Rows[0][“photo”];
                MemoryStreamDataStream = new MemoryStream(Imgdata);
                pictureBox1.Image = new Bitmap(DataStream);
            }
             
        }
    }
}

The post How to retrieve image from database using C# appeared first on Tech Insights.

]]>
https://reactconf.org/how-to-retrieve-image-from-database/feed/ 0 2238