找不到合适的方法来覆盖Asp.net上的错误

时间:2011-03-01 10:45:22

标签: asp.net

我是asp.net的新手。我写了一页asp.net,但是当我运行它时,我得到以下错误。

 public partial class Issueofbook: System.Web.UI.Page
 {
public Int64 Sid;
protected void Page_Load(object sender, EventArgs e)
{
    string Id;
    Id = Request.QueryString.Get(0);

    if (!(IsPostBack == true))
    {
        if (Request.QueryString.Get(1) == "G")
        {
            Sid = Convert.ToInt64(Id);
            if (PopulatedRecord (Sid ) == false)
            {

            }
        }
     }
 }
 private Boolean PopulatedRecord(Int64 Id)
   {
    DataSet DS;
    DS = new DataSet();
    SqlCommand cmd = new SqlCommand();
    SqlDataAdapter da = new SqlDataAdapter();
    SqlConnection Cnn = new SqlConnection();
    string connectionstring;
    connectionstring = @"Datasource=DEVI\SQLEXPRESS;Intial catalog=librarymanagement;Integrated Security=SSPI";
    Cnn.ConnectionString = connectionstring;
    if (Cnn.State != ConnectionState.Open)
        Cnn.Open();
    cmd.Connection = Cnn;
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "usbinsertdatainto";
    cmd.Parameters.Clear();
    cmd.Parameters.AddWithValue("@bookno", "no");
    Adp.SelectCommand = Cmd;
    try
    {
        Adp.Fill(Ds);
    }
    catch (Exception ex)
    {
        throw new ApplicationException(
            "!!! An Error Occured While Update Record In Dtl_SecurityCapital_Upload." + ex.Message);
        lblError.Visible = true;
        lblError.Text = "!!! An Error Occured While " + ex.Message.ToString();
        return false;
    }
    if (DS.Tables[0].Rows.Count > 0)
    {
        txtno.Text = DS.Tables[0].Rows[0]["bookno"].ToString();
        txtstuno.Text = DS.Tables[0].Rows[0]["studentno"].ToString();
        RadioButton1.Text = DS.Tables[0].Rows[0]["currentnoofcopiesavaillable"].ToString();
        RadioButton2.Text = DS.Tables[0].Rows[0]["currentnoofcopiesavaillable"].ToString();
        txtdate.Text = DS.Tables[0].Rows[0]["IssueDate"].ToString();
        txtddate.Text = DS.Tables[0].Rows[0]["Duedate"].ToString();
    }
    cmd.Dispose();
    Cnn.Close();
    Cnn.Dispose();
    return true;
}

protected void Button2_Click(object sender, EventArgs e)
{
    SqlConnection Cnn = new SqlConnection();
    string constr = null;
    SqlCommand cmd = new SqlCommand();
    constr = @"Data Source=DEVI\SQLEXPRESS; Initial Catalog =librarymanagement; Integrated Security=SSPI";
    Cnn.ConnectionString =constr;
    try
    {
        if (Cnn.State != ConnectionState.Open)
            Cnn.Open();
    }
    catch (Exception ex)
    {
        string str1 = null;
        str1 = ex.ToString();
    }
    cmd.Connection = Cnn;
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "uspInsertbookDatainto";
    cmd.Parameters.Clear();
    cmd.Parameters.AddWithValue("@bookno", txtno.Text);
    cmd.Parameters.AddWithValue("@studentno", txtstuno.Text);
    cmd.Parameters.AddWithValue("@Issuedate", txtdate.Text);
    cmd.Parameters.AddWithValue("@Duedate", txtddate.Text);
    if (RadioButton1.Checked==true)
    {
        cmd.Parameters.AddWithValue("@currentnoofcopiesavaillable", RadioButton1.Text);
    }
    if (RadioButton2.Checked == true)
    {
        cmd.Parameters.AddWithValue("@currentnoofcopiesavaillable", RadioButton2.Text);
    }
    try
    {
        cmd.ExecuteNonquery();
    }
    catch (Exception ex)
    {
        throw new ApplicationException("!!! An error an occured while Insert Record Dtl_SecurityCapital_Upload." + ex.Message);
        lblerror.Visible = true;
        lblerror.Text = "!!! An Error occured while ." + ex.Message.ToString();
    }

    finally
    {
        cmd.Dispose();
    }
    Cnn.Close();
    lblError.Text = "New Issue of record suceessfully!!";
    txtno.Text = "";
    txtstuno.Text = "";
    txtdate.Text = "";
    txtddate.Text = "";
}
}

描述:

在编译服务此请求所需的资源期间发生错误。请查看以下特定错误详细信息并相应地修改源代码。

编译器错误消息:

CS0115: 'ASP.issue_of_book_aspx.GetTypeHashCode()': no suitable method found to override

来源错误:

Line 1253:        
Line 1254:        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
Line 1255:        public override int GetTypeHashCode() {
Line 1256:            return -853658727;
Line 1257:        }

有人会指导我吗?谢谢。

1 个答案:

答案 0 :(得分:6)

查看本文可能会对您有所帮助

http://technage.blogspot.com/2008/05/error-gettypehashcode-no-suitable.html

根据我的观察,您的继承名称表示iss_of_book_aspx.cs,并且在您的代码中,您将名称显示为Issueofbook,因此这会有所不同并引发错误,请确保您的.aspx和.aspx.cs名称应该相同