void Accessoriesdb() { accessories.Clear(); String sql = "Data Source=DESKTOP-8TO2TNB;Initial Catalog=car_sales;Integrated Security=True"; SqlConnection con = new SqlConnection(sql); con.Open(); accessories.Clear(); string query = "SELECT *FROM accessories_inf where customerid is null "; SqlCommand cmd = new SqlCommand(query, con); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Accessories_Class a = new Accessories_Class { accessories_id = reader.GetInt32(0), accessories_name = reader.GetString(1), accessories_type = reader.GetString(2), accessories_picture = (byte[])reader["picture"], accessories_price = reader.GetString(4), customer_id = xx }; accessories.Add(a); } }
public void addaccess(Accessories_Class a) { label1.Text = a.accessories_name; label2.Text = a.accessories_price; label3.Text = a.accessories_id.ToString(); MemoryStream mem = new MemoryStream(a.accessories_picture); mem.Seek(0, SeekOrigin.Begin); pictureBox1.Image = Image.FromStream(mem); label4.Text = "access"; label5.Text = a.customer_id.ToString(); }