Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim strConn As String = ""
Dim Cmd As OleDb.OleDbCommand
Dim Con As OleDb.OleDbConnection
Dim Sql As String = Nothing
Dim Reader As OleDb.OleDbDataReader
Dim ComboRow As Integer = -1
Dim Columns As Integer = 0
Con = New OleDb.OleDbConnection("Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=jcompile;Data Source=192.168.1.148")
Sql = "SELECT productname from product"
Cmd = New OleDb.OleDbCommand(Sql, Con)
Con.Open()
Reader = Cmd.ExecuteReader()
While Reader.Read()
For Columns = 0 To Reader.FieldCount - 1
'MsgBox(Reader.Item(Columns).ToString)
Label1.Text = (Reader.Item(Columns).ToString)
Label2.Text = ComboRow + 2 & " rows"
Next
ComboRow += 1
'ProgressBar1.Value += 1
Label3.Text = ComboRow + 1 & " %"
End While
Con.Close()
End Sub
End Class
Public Class Form1
Private WithEvents Timer1 As New Timer
Private dt As New DataTable
Private RowIndex As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Con As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=jcompile;Data Source=192.168.1.148")
Con.Open()
Dim Sql As String = "SELECT productname from product"
Dim Cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(Sql, Con)
Try
dt.Load(Cmd.ExecuteReader())
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
Con.Close()
End Try
RowIndex = 0
Timer1.Interval = 300
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = dt.Rows(RowIndex)(0)
Label2.Text = RowIndex + 2 & " rows"
RowIndex += 1
If RowIndex >= dt.Rows.Count Then Timer.Stop
End Sub
End Class