Salut,
J'ai une Listbox ou je fais du DragDrop.
Celle-ci m'affiche le chemin du fichier.
Avec le bouton save je voudrais uploader pour chaque lien le fichier mais je trouve pas la soluce
Merci de votre aide....
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
62
63 Imports MySql.Data.MySqlClient Imports System.Configuration Imports System.IO Public Class Form2 Dim MysqlConn As MySqlConnection Dim COMMAND As New MySqlCommand Dim READER As MySqlDataReader Private Sub Form2_DragDrop(sender As Object, e As DragEventArgs) Handles Me.DragDrop Dim droppedItems As String() = e.Data.GetData(DataFormats.FileDrop) For Each file In droppedItems Dim filename = GetFileName(file) ListBox1.Items.Add(filename) 'MessageBox.Show("You Dropped " + filename)' Next End Sub Private Sub Form2_DragEnter(sender As Object, e As DragEventArgs) Handles Me.DragEnter If e.Data.GetDataPresent(DataFormats.FileDrop, False) = True Then e.Effect = DragDropEffects.All End If End Sub Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load MysqlConn = New MySqlConnection(ConfigurationManager.ConnectionStrings("xCollectibles.My.MySettings.xcollectiblesConnectionString").ToString) End Sub Public Function GetFileName(path As String) 'Return System.IO.Path.GetFileNameWithoutExtension(path)' Return System.IO.Path.GetFullPath(path) End Function Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim conn As MySqlConnection conn = New MySqlConnection(ConfigurationManager.ConnectionStrings("xCollectibles.My.MySettings.xcollectiblesConnectionString").ToString) Try conn.Open() Catch Myerror As MySqlException MsgBox("Error connection to the database!") End Try Dim adapter As New MySqlDataAdapter Dim sqlquery = "insert into xcollectibles.foto (foto) values (@foto)" Dim myCmd As New MySqlCommand myCmd.Connection = conn myCmd.CommandText = sqlquery myCmd.Parameters.AddWithValue("@foto", ListBox1.Items) adapter.SelectCommand = myCmd Dim mydata As MySqlDataReader mydata = myCmd.ExecuteReader For Each item In ListBox1.Items Next End Sub End Class
Partager