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