不带参数时出现此错误,带参数时没有错误
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
源代码:main.aspx
<body>
<form id="form1" runat="server">
<DIV class="content">
<DIV class="l">
<DIV class="dq"><B>地 区:</B><A class="cF60 fN"
href="http://网站/zhongjie/main.aspx?zjid=<%=Request.QueryString["zjid"].ToString() %>&dqid=0">√全部</A><A
href="http://网站/zhongjie/main.aspx?zjid=<%=Request.QueryString["zjid"].ToString() %>&dqid=1">昌邑区</A><A
href="http://网站/zhongjie/main.aspx?zjid=<%=Request.QueryString["zjid"].ToString() %>&dqid=2">船营区</A><A
href="http://网站/zhongjie/main.aspx?zjid=<%=Request.QueryString["zjid"].ToString() %>&dqid=3">丰满区</A><A
href="http://网站/zhongjie/main.aspx?zjid=<%=Request.QueryString["zjid"].ToString() %>&dqid=4">龙潭区</A><A
href="http://网站/zhongjie/main.aspx?zjid=<%=Request.QueryString["zjid"].ToString() %>&dqid=5">高新区</A><A
href="http://网站/zhongjie/main.aspx?zjid=<%=Request.QueryString["zjid"].ToString() %>&dqid=6">永吉</A><A
href="http://网站/zhongjie/main.aspx?zjid=<%=Request.QueryString["zjid"].ToString() %>&dqid=7">磐石</A><A
href="http://网站/zhongjie/main.aspx?zjid=<%=Request.QueryString["zjid"].ToString() %>&dqid=8">桦甸</A><A
href="http://网站/zhongjie/main.aspx?zjid=<%=Request.QueryString["zjid"].ToString() %>&dqid=9">蛟河</A><A
href="http://网站/zhongjie/main.aspx?zjid=<%=Request.QueryString["zjid"].ToString() %>&dqid=10">舒兰</A></DIV>
<DIV class="list_dh">
<DIV class="list_dh_l">全部信息</DIV>
<DIV class="list_dh_c">位于:<A href="http://www.jl.jl.cn/">吉林市信息港</A> » <A href="http://网站">房产频道</A>
<asp:Label ID="Label1" runat="server"></asp:Label></DIV>
<DIV class="list_dh_r"><A href="http://www.jl.jl.cn/webad/zhiding.htm" target=_blank>?信息如何置顶</A></DIV></DIV>
<DIV id=keylist class="list">
<DL>
<DT class="dt2"><SPAN class="news">置顶</SPAN><A
href="http://www.jl.jl.cn/html/2012/0907/1403428977.htm"
target=_blank>康庄街临街车库出售</A><SPAN class="ding">顶</SPAN><BR><SPAN
class="list_word">昌邑区康庄街永昌二区7号楼52号车库,18平米,私产大照,水电齐全,电动门,临街,可作门市房,2005年建成使用,售价20万。
(<A href="http://网站/chushou/dq-1.aspx">昌邑区</A>)</SPAN></DT>
<DD class="dd2"><SPAN class="price">20</SPAN>万<BR>18平米</DD></DL>
</DIV>
<DIV class="page"><EM>共5897条</EM><SPAN>1</SPAN><A
href="http://网站/chushou/p2.aspx">2</A><A
href="http://网站/chushou/p3.aspx">3</A><A
href="http://网站/chushou/p4.aspx">4</A><A
href="http://网站/chushou/p5.aspx">5</A><A
href="http://网站/chushou/p6.aspx">6</A><A
href="http://网站/chushou/p7.aspx">7</A><A
href="http://网站/chushou/p8.aspx">8</A><A
href="http://网站/chushou/p9.aspx">9</A><A
href="http://网站/chushou/p2.aspx">下一页></A></DIV>
<DIV class="page_fa"><SPAN class="right"><A
href="http://网站/chushou/#top">回到顶部↑</A></SPAN>未找到想要的信息?发布一条信息,让信息主动来找您
<A href="http://www.jl.jl.cn/fabu.aspx">?我要免费发布分类信息</A></DIV></DIV>
<DIV class="r">
<DIV class="abc k208 b_10">
<H5>信息特征筛选查找</H5>
<SCRIPT> shaixuan('/house/chushou/?dqid=0&key=', '&lx=">', '&lx=" class="cF60 fN">√', '/house/chushou/?dqid=0&lx=&key=', '&tp=">', '&tp=" class="cF60 fN">√');</SCRIPT>
</DIV>
<SCRIPT type=text/javascript
src="吉林市二手房吉林市二手房网吉林市二手房产吉林市二手房出售%20-%20吉林市信息港_files/mk1.js"></SCRIPT>
<DIV class="abc k208 b_10">
<H5>赞助商推广链接</H5>
<UL class="r_ad">
<SCRIPT type=text/javascript
src="吉林市二手房吉林市二手房网吉林市二手房产吉林市二手房出售%20-%20吉林市信息港_files/gg.js"></SCRIPT>
</UL></DIV>
<DIV class="k208 left"><A href="http://www.jl.jl.cn/fabu.aspx"><IMG border=0
alt=免费发布信息
src="吉林市二手房吉林市二手房网吉林市二手房产吉林市二手房出售%20-%20吉林市信息港_files/r_fa.gif"></A></DIV></DIV></DIV>
</form>
</body>
main.aspx.cs
public partial class house_zhongjie_main : System.Web.UI.Page
{
Db newdb = new Db();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
fangzj();
}
}
protected void fangzj()
{
int fbj = 1;
int gbj = 1;
string sql = "select * from classad";
if (Request.QueryString["zjid"] != null)
{
string getid = Request.QueryString["zjid"].ToString();
int zjid = Int32.Parse(getid);
fbj = 100;
sql = sql + " where zj=" + zjid + "";
string sqlmc = "select * from fangchan_zj where id=" + zjid + "";
DataSet dsmc = newdb.CommonDataSet(sqlmc);
this.Label1.Text = "» <a href=\"/house/zhongjie/main.aspx?zjid=" + zjid + "\">" + dsmc.Tables[0].Rows[0]["mc"].ToString() + "</a>";
}
else
{
this.Label1.Text = "中介信息";
}
if (Request.QueryString["dqid"] != null)
{
string getdq = Request.QueryString["dqid"].ToString();
int dqid = Int32.Parse(getdq);
gbj = 100;
if (dqid > 0)
{
if (fbj == 100)
{
sql = sql + " and dqid=" + dqid + "";
}
else
{
sql = sql + " where zj>4 and dqid=" + dqid + "";
}
}
}
if (fbj == 1 || gbj == 1)
{
sql = sql + " where zt>0 order by sj_u desc";
}
else
{
sql = sql + " and zt>0 order by sj_u desc";
}
DataSet ds = newdb.CommonDataSet(sql);
}
}
可能是dsmc.Tables[0].Rows[0]["mc"].ToString() 吧,怎么哪行报错都没显示?
不是那个问题
@我是大力水手:
哦,没看到,你更新了问题。没带参数就是页面里的<%=Request.QueryString["zjid"].ToString() %>
不要ToString()