i want to display all the itemcode of the product table in label such that i will rotate like new headline scrolling down in the win form. only 1 value is coming i want to scroll all the values in itemcode + price+ qty product table
Imports System.Data.SqlClient
Imports System.Text
Private sb As StringBuilder = New StringBuilder()
Public Sub Form1()
InitializeComponent()
End Sub
Private Sub timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
Dim direction As Boolean = False
If sb.Length = 0 Then sb.Append(lblMarqueText.Text)
If direction Then
sb.Insert(0, sb(sb.Length - 1))
sb.Remove(sb.Length - 1, 1)
Else
sb.Append(sb(0))
sb.Remove(0, 1)
End If
lblMarqueText.Text = sb.ToString()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Timer1.Start()
SetProductMarqueText()
End Sub
Private Sub SetProductMarqueText()
Dim ProductList As String = ""
Dim constring As String = "Server=.\SQL2005;Database=NorthWind;uid=sa;pwd=pass@123;"
Dim Conn As SqlConnection = New SqlConnection(constring)
Conn.Open()
Dim cmd As SqlCommand = New SqlCommand("SELECT Top 10 [ProductName] FROM [Products]", Conn)
Dim dr As SqlDataReader = cmd.ExecuteReader()
While dr.Read()
ProductList += dr("ProductName") & ", "
End While
Conn.Close()
lblMarqueText.Text = ProductList
End Sub