ServerVersion = “cn.ServerVersion”引发了“System.InvalidOperationException”类型的异常
用.net的分页控件AspNetPager绑定显示时,
public DataSet count(int index, int max, string sql)
{
using (SqlConnection cn = new SqlConnection("server=.;database=student;uid=sa;pwd="))
{
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(sql, cn);
if (index == 0 && max == 0)
{
da.Fill(ds);
}
else
da.Fill(ds, index, max, "score");
return ds;
}
}
会出错,在 using (SqlConnection cn = new SqlConnection("server=.;database=student;uid=sa;pwd="))
会提示说:
ServerVersion = “cn.ServerVersion”引发了“System.InvalidOperationException”类型的异常
请问怎么解决呢?谢谢
------解决方案--------------------
关闭VS,再断点调试下