You are on page 1of 2

C:\Users\shiva\OneDrive\Documents\Visual ... Generator\WindowsFormsApplication1\Form3.

cs 1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Net;

namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-SHIVA\SQLEXPRESS;Initial
Catalog=shivam1;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
string str;

public Form3()
{
InitializeComponent();

label1.Visible=label2.Visible = label3.Visible = label4.Visible = label5.Visible


= label6.Visible=label7.Visible = false;
}

private void buttonShow_Click(object sender, EventArgs e)


{
str = "Select * from product where name='" + textBox1.Text+ "'";

con.Open();
cmd.Connection = con;
cmd.CommandText = str;

SqlDataReader rdr = cmd.ExecuteReader();

while (rdr.Read())
{
id.Text = rdr.GetInt32(0).ToString();
name.Text=rdr.GetString(1);
price.Text = rdr.GetInt32(2).ToString();
manufacturer.Text = rdr.GetString(3);
description.Text = rdr.GetString(4);
//code for displaying image(barcode)
Byte[] byteBLOBData = new Byte[0];
byteBLOBData = (Byte[])((byte[])rdr["img"]);
System.IO.MemoryStream ms = new System.IO.MemoryStream(byteBLOBData);
barcode.Image = System.Drawing.Image.FromStream(ms);
}

con.Close();

label1.Visible = label2.Visible = label3.Visible = label4.Visible = label5.


Visible = label6.Visible =label7.Visible = true;

}
C:\Users\shiva\OneDrive\Documents\Visual ... Generator\WindowsFormsApplication1\Form3.cs 2
}

You might also like