Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Message: Type or namespace definition, or end-of-file expected [closed]

Tags:

c#

c#-4.0

I've searched the internet, all previous answers said that a semicolon is missing. That's not the problem. What else can cause this error? In the third site, several people asked this question but this scenario is different.

Error is > Type or namespace definition, or end-of-file expected

 public partial class SeenSMS : System.Web.UI.UserControl
    {
    //temp sql connection
    //public SqlConnection mycon;
    SqlConnection mycon = new SqlConnection(@"Data Source=ASOFT20\MAMUT;Initial   Catalog=ViltraNew;UserID=sa;Password=sa123");


    protected void Page_Load(object sender, EventArgs e)
    {
        string[] msg_arr = Request.QueryString["arr"].Split('|');

        if (!IsPostBack)
        {
            string Moose = Request.QueryString[1];
        }

        if (msg_arr != null)
        {
            if ((msg_arr.Length == 3) && (msg_arr[1].ToLower() == "slett"))

            {
                int Hours = Convert.ToInt32(msg_arr[2]);

                if (Hours > 0)
                {   
                    string username = msg_arr[0];

                    SqlCommand com = new SqlCommand("SELECT count(*) as count  FROM Animal Where Hours=@Hours", mycon);
                    com.Parameters.AddWithValue("@Hours",Hours);
                    using (SqlDataReader reader = com.ExecuteReader())
                    {
                        if(reader.HasRows)
                        {
                        while (reader.Read())
                        {
                             // int number = Convert.ToInt32(con.ExecuteReader());
                            int number = Convert.ToInt32(reader["count"]);

                        }
                        }
                        else{

                        }
                    }
                }
             //   if( number == 0)
               // {
                   // Response.Write("Improper Plain Summaries.");
              //  }
             //   else
                {

                }


                }
            }


        }

  public  bool number { get; set; }
  public  object Hours { get; set; }}



   // public System.Collections.Specialized.NameValueCollection Moose { get; set; }



  //  public string Value { get; set; }

  //  public object msg_arr { get; set; }
}
 }
like image 819
TechGuy Avatar asked Jun 11 '12 07:06

TechGuy


3 Answers

This line:

public  object Hours { get; set; }}

Your have a redundand } at the end

like image 92
Jürgen Steinblock Avatar answered Nov 14 '22 18:11

Jürgen Steinblock


You have extra brackets in Hours property;

public  object Hours { get; set; }}
like image 8
stay_hungry Avatar answered Nov 14 '22 16:11

stay_hungry


  1. Make sure you have System.Web referenced
  2. Get rid of the two } at the end.
like image 3
Po-ta-toe Avatar answered Nov 14 '22 16:11

Po-ta-toe