{"Fill: SelectCommand.Connection 属性尚未初始化。"}
主要代码:返回dataset的函数:
public static DataSet dataset(string sqlstr)
{
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter();
try
{
getconn();
= CommandType.Text;
= sqlstr;
da.SelectCommand = comm;
da.Fill(ds);
}
catch (Exception err)
{
throw new Exception(err.Message);
}
finally
{
closeconn();
}
return ds;
}
调用函数的代码:
try
{
string seltxt = "select * from users where username='"+uid+"'";
DataSet dst = new DataSet();
dst=dbaccess.dataset(seltxt);
if (dst.Tables[0].Rows.Count <= 0)
{
Response.Write("<script>alert(\"用户名不存在!\");</script>");
return;
}
}
catch (Exception err)
{
throw new Exception(err.Message);
}
然后就异常了,提示:{"Fill: SelectCommand.Connection 属性尚未初始化。"}
getconn()单独测试过,没问题的
求助各位高手,谢谢