-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFrmImage.vb
More file actions
61 lines (51 loc) · 1.99 KB
/
FrmImage.vb
File metadata and controls
61 lines (51 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Imports System.IO
Imports System.Data.SqlClient
Imports MONIN_CONTACT.dbconnect
Public Class FrmImage
Private Sub FrmImage_Load(sender As Object, e As EventArgs) Handles MyBase.Load
cnn = New SqlConnection(connectionString)
cnn.Open()
cmd = New SqlCommand()
cmd.Connection = cnn
cmd.CommandText = "SELECT LibProduit FROM PRODUIT"
reader = cmd.ExecuteReader()
While (reader.Read)
ComboBox1.Items.Add(reader.GetValue(0))
End While
reader.Close()
cnn.Close()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim openFileDialog1 As New OpenFileDialog()
Dim a As String
openFileDialog1.Title = "Choisissez une image"
openFileDialog1.Filter = "Tous(*.*)|*.*"
openFileDialog1.FilterIndex = 1
openFileDialog1.ShowDialog()
a = openFileDialog1.FileName
My.Computer.FileSystem.CopyFile(a, "C:\Users\jason_000\Desktop\Images\" & Dir(a), overwrite:=False)
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim path As String
Dim IdProd As Integer
cnn.Open()
cmd = New SqlCommand()
cmd.Connection = cnn
cmd.CommandText = "SELECT idProduit FROM PRODUIT WHERE libProduit = '" & ComboBox1.Text & "'"
reader = cmd.ExecuteReader()
reader.Read()
IdProd = reader.GetValue(0)
reader.Close()
cnn.Close()
cnn.Open()
cmd = New SqlCommand()
cmd.Connection = cnn
cmd.CommandText = "SELECT photo FROM PRODUIT WHERE idProduit = '" & IdProd & "'"
reader = cmd.ExecuteReader()
reader.Read()
path = "C:\Users\jason_000\Desktop\Images\" & reader.GetValue(0)
reader.Close()
cnn.Close()
PictureBox1.ImageLocation = path
End Sub
End Class