在列表视图中显示来自sql数据库的数据 [英] Display data from sql database in a list view

查看:117
本文介绍了在列表视图中显示来自sql数据库的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Am在列表视图中显示数据.但是在 lv.Show(); 行,我收到一条错误消息"ExecuteReader需要打开且可用的连接"
请问我该怎么办?

Am displaying data in a List View. But at the line lv.Show(); I get an error message "ExecuteReader requires an open and available connection"
Please what should I do?

public bool searchpersonDetails(string personid, string personname)
{
  conn.Open();
  if (client_id == null)
  {
    Fom1 lv = new Fom1(personname);
    lv.Show();
  }
}

推荐答案

问题很可能出在Form1类代码中.放置一个断点,然后按F11(进入)以查看其中发生了什么.
Most likely the problem is inside the Form1 classes code. Put a breakpoint and then press F11 (step into) to see what''s going on in there. Somewhere in there you use a reader without an open connection.


根据错误消息判断,您可能尚未在Form1中的任何位置关闭连接.您可以按照mika的建议通过调试轻松地解决此问题. .

希望对您有所帮助:)
judging by the error message you may have not closed the connection anywhere in Form1 .You can easily resolve this by debugging as suggested by mika.

hope it helps :)


这篇关于在列表视图中显示来自sql数据库的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆