如何在VB.NET中关闭DataReader?

时间:2013-12-04 15:12:43

标签: vb.net datareader

从数据库执行或加载数据列表时遇到错误。已经有一个与此Connection关联的开放DataReader,必须先关闭它。我不知道如何解决它。我对解决这个问题一无所知。我键入dr.close但没有任何反应。请帮我。如果有人知道。非常感谢你!

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 个答案:

没有答案