private void Upload(object sender, RoutedEventArgs e) { try { int dsCode = Convert.ToInt32(Name_txt.Text); byte[] images = null; FileStream stream = new FileStream(imglocation,FileMode.Open,FileAccess.Read); BinaryReader brs = new BinaryReader(stream); images = brs.ReadBytes((int)stream.Length); SqlCommand insertCMD = new SqlCommand("insert into DesignTB(DesignCode,DesignIMG) values(@dsCode,@images)"); insertCMD.Parameters.AddWithValue("@dsCode",dsCode); insertCMD.Parameters.AddWithValue("@images",images); int row = dBAccess.executeQuery(insertCMD); if (row == 1) { ManageStock manageStock = new ManageStock(); manageStock.LoadList(); Close(); } } catch (Exception) { MessageBox.Show("Unsuccessful"); } } }}
public void LoadList() { string query = "select * from DesignTB"; dBAccess.readDatathroughAdapter(query, dt); lstBox.ItemsSource = dt.DefaultView; dBAccess.closeConn(); }