By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

i have 7 listbox no. of items when i click 3 listbox item it will dispaly image

P: 1
Here my code.vb.net with forms
i want to retrieve the images from sql server when i click item in listbox dynamically change and display the image in picture box
Expand|Select|Wrap|Line Numbers
  1. ListBox4.Items.Clear()
  2.         ListBox5.Items.Clear()
  3.         ListBox6.Items.Clear()
  4.         ListBox7.Items.Clear()
  5.         Dim connString As String = "Data Source=HASEE-PC\SQLEXPRESS1;uid=sa;pwd=test123;database=TDM"
  6.         Dim conn As New SqlConnection(connString)
  7.  
  8.         conn.Open()
  9.         'For i As Integer = 0 To ListBox1.SelectedItems.Count - 1
  10.         '    users = ListBox1.SelectedItem(i).ToString
  11.         'Next
  12.         Dim sql As String = "  SELECT DISTINCT man   from kdblist where  subassembly='" + ListBox1.SelectedItem + "' AND operation='" + ListBox2.SelectedItem + "'AND issues='" + ListBox3.SelectedItem + "'"
  13.         Dim cmd As New SqlCommand(sql, conn)
  14.         'Dim tracebox As String
  15.         Dim reader As SqlDataReader = cmd.ExecuteReader()
  16.         Do While (reader.Read)
  17.  
  18.             ListBox4.Items.Add(reader("man").ToString)
  19.             ' ListBox5.Items.Add(reader("method").ToString)
  20.             ' ListBox6.Items.Add(reader("material").ToString)
  21.             ' ListBox7.Items.Add(reader("machine").ToString)
  22.             PictureBox1.ImageLocation = "C:\Visual_Basic_Projects\movies_01\movies_01\bin\ Debug\thumb_pics\" & "tn_" & TextBoxPictureFilePath.Text & ".jpg"
  23.         Loop
  24.         ' If ListBox4.Text = "" Then
  25.         'ListBox5.Items.Add(reader("material").ToString)
  26.         'End If
  27.  
  28.  
  29.  
  30.     End Sub
Apr 14 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.