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 64 65 66 67 68 69
|
Public Class Form1
Public sqlconnection As SqlConnection
Dim connectionString As String = "******"
Dim connection As New SqlClient.SqlConnection(connectionString)
Dim dt As New DataTable
Dim dt1 As New DataTable
Dim dt2 As New DataTable
Dim dt3 As New DataTable
Dim sql As String = "requete 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.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 = "requete 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
BackgroundWorker1 = New BackgroundWorker
BackgroundWorker1.WorkerReportsProgress = True
BackgroundWorker1.RunWorkerAsync()
'Timer2.Interval = 15000
'Timer2.Start()
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 = "requete 3"
Dim dataadapter2 As New SqlDataAdapter(sql2, connection)
dataadapter2.Fill(dt2)
e.Result = dt2
dataadapter2.Dispose()
Dim i As Integer
For i = 0 To 9
Dim variable As String = DataGridView1.Item(0, i).Value.ToString
Dim sql3 As String = "requete 4"
Dim dataadapter3 As New SqlDataAdapter(sql3, connection)
dataadapter3.Fill(dt3)
dataadapter3.Dispose()
Next i
e.Result = dt3
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)
Dim dt3 As DataTable = DirectCast(e.Result, DataTable)
Me.DataGridView1.DataSource = dt2
Me.DataGridView2.DataSource = dt3
End Sub |
Partager