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
| Dim sql As String = "requête 1"
Dim dataadapter As New SqlDataAdapter(Sql, connection)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
connection.Open()
dataadapter.Fill(dt)
DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
DataGridView2.SelectionMode = DataGridViewSelectionMode.FullRowSelect
DataGridView1.DataSource = dt
Dim i As Integer
For i = 0 To 9
Dim variable As String = DataGridView1.Item(0, i).Value.ToString
Dim sql1 As String = "requête 2"
Dim dataadapter1 As New SqlDataAdapter(sql1, connection)
dataadapter1.Fill(dt1)
Next i
DataGridView2.DataSource = dt1
Timer1.Interval = 10000
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
dataadapter.Dispose()
BackgroundWorker1 = New BackgroundWorker
BackgroundWorker1.WorkerReportsProgress = True
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim worker As BackgroundWorker = DirectCast(sender, BackgroundWorker)
Try
Dim sql2 As String = "requête 3"
Dim dataadapter2 As New SqlDataAdapter(sql2, connection)
dataadapter2.Fill(dt2)
e.Result = dt2
dataadapter2.Dispose()
Catch ex As Exception
End Try
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, _
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
Dim dt2 As DataTable = DirectCast(e.Result, DataTable)
Me.DataGridView1.DataSource = dt2
End Sub |
Partager