How to close DataReader in VB.NET?

1.6k views Asked by At

I encounter error when executing or loading list of data from database. There is already an open DataReader associated with this Connection which must be closed first. i don;t know how to fix it. i don't have any idea on fixing this. I typed dr.close but nothing happens. please help me. if someone know. thank you so much!

Dim sqlquery As String = "SELECT * FROM complaint WHERE status='On-process'"
Dim sqladapter As New MySqlDataAdapter
Dim sqlcmd As New MySqlCommand
Dim table As New DataTable
Dim i As Integer

With sqlcmd
    .CommandText = sqlquery
    .Connection = connectionsrvr
End With

With sqladapter
    .SelectCommand = sqlcmd
    .Fill(table) ------------->this is the error..
End With

For i = 0 To table.Rows.Count - 1
    With lvlistview
        .Items.Add(table.Rows(i)("dte"))
        With .Items(.Items.Count - 1).SubItems
            .Add(table.Rows(i)("tran_no"))
            .Add(table.Rows(i)("comp_type"))
            .Add(table.Rows(i)("status"))
            .Add(table.Rows(i)("sys_name"))
            .Add(table.Rows(i)("mod_name"))
            .Add(table.Rows(i)("err_desc"))
            .Add(table.Rows(i)("trigg"))
            .Add(table.Rows(i)("comp_fname") & " " & table.Rows(i)("comp_lname"))
            .Add(table.Rows(i)("comp_pos"))
        End With
   End With
Next
0

There are 0 answers