未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
源错误:
行 52: ds.Clear()
行 53: ds = GetDataFromDB(sqlstr)
行 54: If ds.Tables(0).Rows.Count > 0 Then
行 55: sqlstr = "select * from userid where(用户名='" & strid & "') and ( 密码='" & pwd & "')"
行 56: Dim myds As DataSet
源文件: c:\inetpub\wwwroot\WebApplication1\webfrmlogin.aspx.vb 行: 54
堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。]
WebApplication1.webfrmlogin.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebApplication1\webfrmlogin.aspx.vb:54
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
--------------------编程问答-------------------- 一般是变量为null 建议try catch下 --------------------编程问答-------------------- 应该是 GetDataFromDB 没有返回值 --------------------编程问答-------------------- ds.Tables(0) 没取到
ds是空的
--------------------编程问答-------------------- If ds.Tables(0).Rows.Count > 0 Then 在这句话之前加上
try
{
if(ds.tables(0).Rows.count);
}
catch(Exception e)
{
response.write(e.tostring());
}
看看有没有数据,可能你的ds.Tables(0).Rows.Count为null.那么就错了! --------------------编程问答-------------------- ds 沒數據。 --------------------编程问答-------------------- 这种问题就在那种得到或者取值的地方设置断点,一看就出来了
补充:.NET技术 , ASP.NET