标题:VB.NET数据循环显示
只看楼主
h3wuzw
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-10-28
 问题点数:0 回复次数:1 
VB.NET数据循环显示
数据库表有101条记录,要滚动循环显示
搜索更多相关主题的帖子: 数据库表 记录 
2015-10-30 18:57
h3wuzw
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-10-28
得分:0 
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
2015-10-31 22:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-458736-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.049641 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved