目前在为单位写一个网站!(以前是ASP的)目前在学.net所以就用C#来写程序了!
C#的数据库操作很麻烦,于是想写一个数据库组件。但是出了我意想外的错误!大家帮我看看!
这是DLL文件的源码
namespace System.Data
public class mydata
{
                  public mydata
                  {}
public OleDbDataReader read(string sql,string datapath)
{
                      string strconn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+datapath+";";
conn=new OleDbConnection(strconn);
OleDbDataReader oread=new OleDbCommand(sql,conn).ExecuteReader();
conn.Close();
         return oread;
                  }
          }
这里是页面引用的代码
mydata dr=new mydata();
OleDbDataReader s=mydata.read("sql语句","数据库地址");
while(s.read())
{
Response.write(s[列名].toString);
}
非常简单的代码!各位大大们一定能看明白!
但是出现的结果是
=========================================================================================
ExecuteReader 需要打开的并且可用的连接。该连接的当前状态是 Closed。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.InvalidOperationException: ExecuteReader 需要打开的并且可用的连接。该连接的当前状态是 Closed。
=========================================================================================
这是怎么回事呀!就算我去掉conn.Close();也还是不行!我实在想不出原因!哪位高手知道?