本文介绍了如何清除错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

namespace rathana
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack == true)
            {
                populatecombobox();
                txtAmountDisplay();
            }
        }
        private void populatecombobox()
        {
            DataSet Ds;
            Ds = new DataSet();
            SqlCommand Cmd = new SqlCommand();
            SqlDataAdapter Adp = new SqlDataAdapter();
            SqlConnection Cnn = new SqlConnection();
            string ConnectionString;
            Cnn.ConnectionString = @"Data Source=DEVI\SQLEXPRESS; Initial Catalog =photo; Integrated Security=SSPI";

            if (Cnn.State != ConnectionState.Open)
                Cnn.Open();
            Cmd.Connection = Cnn;
            Cmd.CommandType = CommandType.StoredProcedure;
            Cmd.CommandText = "UspGetDataFromtblSize";
            Cmd.Parameters.Clear();
            //Cmd.Parameters.AddWithValue("@Id", Id);
            Adp.SelectCommand = Cmd;
            try
            {
                Adp.Fill(Ds);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(
                    "!!! An Error Occured While getting Data From tblSize." + ex.Message);
                lblError.Visible = true;
                lblError.Text = "!!! An Error Occured While " + ex.Message.ToString();
                return;
            }
            if (Ds.Tables[0].Rows.Count > 0)
            {
                cmbSize.DataSource = Ds;
                cmbSize.DataTextField = "Size";
                cmbSize.DataValueField = "SizeID";
                cmbSize.DataBind();
            }
            Cmd.Dispose();
            Cnn.Close();
            Cnn.Dispose();
            return;
        }
        }
        private void txtAmountDisplay()
        {

            Int32 str;
            SqlCommand Cmd = new SqlCommand();
            SqlConnection Cnn = new SqlConnection();
            string ConnectionString;
            Cnn.ConnectionString = @"Data Source=DEVI\SQLEXPRESS; Initial Catalog =photo; Integrated Security=SSPI";
            if (Cnn.State != ConnectionState.Open)
                Cnn.Open();
            Cmd.Connection = Cnn;
            Cmd.CommandType = CommandType.StoredProcedure;
            Cmd.CommandText = "sproc_Ins_RATE_PhotoSettingsDetail";
            Cmd.Parameters.Clear();
            // Cmd.Parameters.AddWithValue("@Id", txtBillNo.Text);
            Cmd.Parameters.AddWithValue("@SizeID", cmbSize.SelectedValue);
            //  Cmd.Parameters.AddWithValue("@Rate", txtAmt.Text.ToString());
            try
            {
                str = Convert.ToInt32(Cmd.ExecuteScalar());
                txtAmt.Text = str.ToString();
            }
            catch (Exception ex)
            {
                throw new ApplicationException(
                    "!!! An Error Occured While getting Data From tblRate." + ex.Message);
                lblError.Visible = true;
                lblError.Text = "!!! An Error Occured While " + ex.Message.ToString();
                return;
            }

            Cmd.Dispose();
            Cnn.Close();
            Cnn.Dispose();
            return;

        }
        protected void cmbSize_SelectedIndexChanged1(object sender, EventArgs e)
        {
            txtAmountDisplay();
            if ((txtAmt.Text != "") && (txtNoofcopies.Text != ""))
            {
                txtTot.Text = Convert.ToString(Convert.ToInt32(txtNoofcopies.Text) * Convert.ToInt32(txtAmt.Text));
                //lblTotal.Text = Convert.ToString(Convert.ToInt32(lblTotal.Text) + Convert.ToInt32(txtTot.Text));
            }
            else
            {
                txtTot.Text = Convert.ToString(0);
                // lblTotal.Text = Convert.ToString(0);
            }

        }
        private DataSet GetData()
        {
            DataSet Ds;
            Ds = new DataSet();
            SqlCommand Cmd = new SqlCommand();
            SqlDataAdapter Adp = new SqlDataAdapter();
            SqlConnection Cnn = new SqlConnection();
            string ConnectionString;
            Cnn.ConnectionString = @"Data Source=DEVI\SQLEXPRESS; Initial Catalog =photo; Integrated Security=SSPI";

            if (Cnn.State != ConnectionState.Open)
                Cnn.Open();
            Cmd.Connection = Cnn;
            Cmd.CommandType = CommandType.Text;
            Cmd.CommandText = "select Size,0 as Amount,'''' As Noofcopies from tblSize where SizeID=0";
            Cmd.Parameters.Clear();
            //Cmd.Parameters.AddWithValue("@Id", Id);
            Adp.SelectCommand = Cmd;
            try
            {
                Adp.Fill(Ds);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(
                    "!!! An Error Occured While getting Data." + ex.Message);
                //lblErrorMsg.Visible = true;
                //lblErrorMsg.Text = "!!! An Error Occured While " + ex.Message.ToString();
            }
            Cmd.Dispose();
            Cnn.Close();
            Cnn.Dispose();
            return Ds;
        }


    }
}
Error   1   Expected class, delegate, enum, interface, or struct    C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\rathana\rathana\Default.aspx.cs    74  17  rathana
Error   2   Expected class, delegate, enum, interface, or struct    C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\rathana\rathana\Default.aspx.cs    79  34  rathana
Error   3   Expected class, delegate, enum, interface, or struct    C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\rathana\rathana\Default.aspx.cs    80  37  rathana
Error   4   Expected class, delegate, enum, interface, or struct    C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\rathana\rathana\Default.aspx.cs    102 27  rathana
Error   5   A namespace does not directly contain members such as fields or methods C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\rathana\rathana\Default.aspx.cs    111 13  rathana
Error   6   Type or namespace definition, or end-of-file expected   C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\rathana\rathana\Default.aspx.cs    118 9   rathana

推荐答案


这篇关于如何清除错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 19:42