invalidateopenrationexception

来源:百度知道 编辑:UC知道 时间:2024/06/12 07:20:40
在第一次读取数据后好像是关闭了 read 。再读数据的时候就 报:invalidateopenrationexception 异常。请问怎么解决?

关闭了read你还怎么读数据
第一次读数据后别关闭它~
你可以在调用结束后让它自动关闭
using(SqlDataReader reader=new SqlDataReader("写你的Reader") )
{
//操作
}

你需要保证在读取的时候connection是开启的,每次读一个数据项

因为不像是dataadapter,一次性填充到数据集