无法计算表达式,因为当前方法的代码是优化错误

时间:2017-07-24 03:56:04

标签: c# asp.net sql-server

我得到了:先前位置0没有行。在调试中我发现表Select_By_SNAME_BLOCKNO的计数为0。

此外,当我放置断点时,我得到的某些列无法计算表达式,因为当前方法的代码是优化错误。 那么这里出了什么问题?

以下是收到错误的代码块:

 DS_HOUSE.HOUSE_SELECTDataTable HDT = new DS_HOUSE.HOUSE_SELECTDataTable();
DS_HOUSETableAdapters.HOUSE_SELECTTableAdapter HAdapter = new DS_HOUSETableAdapters.HOUSE_SELECTTableAdapter();
DS_USER.USERMST_SELECTDataTable UDT = new DS_USER.USERMST_SELECTDataTable();
DS_USERTableAdapters.USERMST_SELECTTableAdapter UAdapter = new DS_USERTableAdapters.USERMST_SELECTTableAdapter();

  protected void Page_Load(object sender, EventArgs e)
{   
        lblsell.Text = "";
        UDT = UAdapter.Select_By_UID(Convert.ToInt32(Session["uid"].ToString()));
        HDT = HAdapter.Select_By_SNAME_BLOCKNO(UDT.Rows[0]["societyname"].ToString(), Convert.ToInt32(UDT.Rows[0]["HID"].ToString()));


            ViewState["HID"] = HDT.Rows[0]["HID"].ToString();
                        lblbno.Text = HDT.Rows[0]["blockno"].ToString();
            lbltype.Text = HDT.Rows[0]["type"].ToString();
            lblsname.Text = HDT.Rows[0]["sname"].ToString();
            Image3.ImageUrl = HDT.Rows[0]["image"].ToString();
             }

以下是Select_By_SNAME_BLOCKNO

的定义
         public virtual DS_HOUSE.HOUSE_SELECTDataTable Select_By_SNAME_BLOCKNO(string sname, global::System.Nullable<int> bno) {
        this.Adapter.SelectCommand = this.CommandCollection[5];
        if ((sname == null)) {
            this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value;
        }
        else {
            this.Adapter.SelectCommand.Parameters[1].Value = ((string)(sname));
        }
        if ((bno.HasValue == true)) {
            this.Adapter.SelectCommand.Parameters[2].Value = ((int)(bno.Value));
        }
        else {
            this.Adapter.SelectCommand.Parameters[2].Value = global::System.DBNull.Value;
        }
        DS_HOUSE.HOUSE_SELECTDataTable dataTable = new DS_HOUSE.HOUSE_SELECTDataTable();
        this.Adapter.Fill(dataTable);
        return dataTable;
    }

此外,存储过程Select_By_SNAME_BLOCKNO代码为:

create procedure Select_By_SNAME_BLOCKNO
@sname nvarchar(50),
@bno int
AS
BEGIN 
  select * from dbo.HouseMst where Sname=@sname and blockno=@bno

这会返回值,但我无法在页面上检索。

0 个答案:

没有答案