sqlite help

Hollowman 41 Reputation points
2021-06-15T17:29:50.57+00:00

hello, I want to add the data I have taken to the form with the user control. but the items in the last column are coming, where am I doing wrong?

    Try
        Dim DB_Path As String = "Data Source=" & Application.StartupPath & "\Data.db;"
        Dim conn As New SQLiteConnection(DB_Path)
        conn.Open()
        Dim SQL As String = "SELECT * from torrent;"
        Dim da As New SQLiteDataAdapter(SQL, conn)
        Dim ds As New DataSet
        da.Fill(ds, "torrent")

        conn.Close()

        Dim Useram As New UserControl2

        For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
            Useram.Label1.Text = ds.Tables(0).Rows(i).Item(0).ToString()
            Useram.Label2.Text = ds.Tables(0).Rows(i).Item(1).ToString()
            Useram.Label3.Text = ds.Tables(0).Rows(i).Item(2).ToString()
            FlowLayoutPanel1.Controls.Add(Useram)
        Next
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

hmy6zb3.png
105837-1.png

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,713 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 116.6K Reputation points
    2021-06-15T17:44:32.967+00:00

    Try creating the control inside the loop:

    For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
       Dim Useram As New UserControl2
       . . .
    Next 
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.