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

Recommended Answers

All 2 Replies

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

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

commented: pointless cut and paste from original question - with no attempt to answer... sigh -2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.