0

this code runs at my other sample prog. but when I try to use it to my actual prog., it wont work. (variables changed, connection's ok) . . . cant show data at listview

Imports MySql.Data.MySqlClient

Public Class Form1
    Public sconnection As New MySqlConnection
    Private Sub Form1_Load()
        If sconnection.State = ConnectionState.Closed Then
            sconnection.ConnectionString = "server=localhost;User Id=root;database=t11"
            sconnection.Open()
        End If
        loadfile()
    End Sub
    Public Sub loadfile()
        Dim squery As String = "select * from tbl_list"
        Dim sadapter As New MySqlDataAdapter
        Dim scommand As New MySqlCommand
        Dim sqltable As New DataTable
        Dim i As Integer

        With scommand
            .CommandText = squery
            .Connection = sconnection
        End With

        With sadapter
            .SelectCommand = scommand
            .Fill(sqltable)
        End With

        For i = 0 To stable.Rows.Count - 1
            With ListView1
                .Items.Add(sqltable.Rows(i)("id"))
                With .Items(.Items.Count - 1).SubItems
                    .Add(sqltable.Rows(i)("name"))
                    .Add(sqltable.Rows(i)("no"))
                    .Add(sqltable.Rows(i)("company"))
                End With
            End With
        Next
    End Sub
End Class
3
Contributors
2
Replies
26
Views
5 Years
Discussion Span
Last Post by Alvin_1
0

Is the listview view property set to Details?

If this property is not set to details, no columns can be shown.

Please see here for help

Hope this helps

-1

sconnection.ConnectionString = "server=localhost;User Id=root;password = ;database=t11"

Votes + Comments
pointless cut and paste from original question - with no attempt to answer... sigh
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.