Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center .
Closed 10 years ago .

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 expecte d

 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; }
                I get lost in the number of closing braces, no wonder the compiler does too. Stuff like this wouldn’t happen with proper code formatting.
– Konrad Rudolph
                Jun 11, 2012 at 7:55
                This question is clearly helping some future visitors -- someone even favorited it. It's hard to predict what will help a newbie (or not so newbie) in the future.
– Jaime
                Nov 22, 2015 at 19:35
                I just had this error and went through all my {} and semi-colons and couldn't find anything wrong.  It was driving me crazy.  It turned out that VS Code was just confused.  I closed it and re-opened, and the problem mysteriously vanished.
– technonaut
                Aug 20, 2020 at 15:12
                Me, same problem today. Visual Studio Community 2019 was apparently confused. Closed VS and restarted it, and voila no errors.
– Whitzz
                Oct 1, 2021 at 0:14