我不明白为什么它会抛出这个错误。代码对我来说似乎很好,任何人都可以发现我哪里出错了?我正在尝试匹配数据库中的用户名和密码。谢谢
Line 20: myData = loginservice.AdminGetUserTable();
Line 21:
Line 22: foreach (DataRow myRow in myData.Tables["Users"].Rows)
Line 23: {
Line 24: if (txt_username.Text == myRow["Username"].ToString() && txt_password.Text == myRow["Password"].ToString())
错误:
[NullReferenceException: Object reference not set to an instance of an object.]
Login.Button1_Click(Object sender, EventArgs e) in f:\.NetProject\WebSite\Login.aspx.cs:22
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9553178
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724