VB.NET数据循环显示
数据库表有101条记录,要滚动循环显示
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Dim cn As SqlConnection
Dim ml As SqlDataAdapter
Dim am As SqlCommand
Dim ds As DataSet
Dim at As String
Private itms As Integer
Private itm As Integer
Private Sub InitializeTimer()
itms = 0
itm = 4
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cnm As String = "Data Source=(local);Initial Catalog=DB_1001;Integrated Security=False;User ID=sa;Password=123;"
cn = New SqlConnection(cnm)
Timer1.Enabled = True
DataGridView1.AllowUserToAddRows = False
DataGridView1.RowHeadersVisible = False
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
itm = 6
If itms < 15 Then
Timer1.Interval = 2000
Dim sql As String = "select top (" + Convert.ToString(itm) + ") id,names,email from aatest where id not in(select top(" + Convert.ToString(itms) + ") id from aatest) "
ml = New SqlDataAdapter(sql, cn)
ds = New DataSet
ml.Fill(ds, "abc")
DataGridView1.DataSource = ds.Tables("abc")
itms = itms + 6
DataGridView1.AutoGenerateColumns = False
If itms >= 15 Then
itms = 0
End If
End If
End Sub
End Class