即时通讯设计我的网页,因为我已经输入了书籍ID并键入 Nameofthebook。然后单击按钮本书的堆栈都可以是去到另一个页面,然后不可用是显示错误消息是本书不可用我的项目(图书管理系统)Asp.net如何纠正错误
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Bookcheck : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string constr = null;
constr =
ConfigurationManager.ConnectionStrings["librarymanagementconnetionstring"].ConnectionStrin
g
;
SqlConnection cnn = new SqlConnection(constr);
cnn.Open();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter("SELECT*FROM BOOKREGISTRATIONDETAILS WHERE
bookId='" + txtid.Text.Trim() + "'AND Nameofbook='" + txtnb.Text.Trim() + "'",
constr);
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
Response.Redirect("Issueofbook.aspx");
}
else
{
Msg.Text = "NO book available";
Msg.Visible = true;
}
}
}
}
My error
NULL reference exception in un handle by the user
constr =
ConfigurationManager.ConnectionStrings["librarymanagementconnetionstring"].ConnectionStrin
g;
请尽量将代码格式化为可读状态。提示:在Visual Studio中,选择要包含的代码,按 + ,直到最外层的范围没有缩进,复制并粘贴到编辑器中,选择代码,然后按 + 。这看起来很整齐。 –
2011-03-17 10:13:28
格式化消息时,请确保您编写了完整的代码,然后选择了整个代码,然后单击工具栏按钮将其标记为代码段。现在你的帖子是不可读的,至少对我而言。 – Tengiz 2011-03-17 10:14:46