Results 1 to 2 of 2

Thread: [RESOLVED] strange error

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2006
    Location
    Surrey
    Posts
    20

    Resolved [RESOLVED] strange error

    i swear soemtimes code is right but visual studio is just being silly, i've had times where the code is perfect but theres an error which is solved if u make a new project and paste in the same code:

    Code:
    public partial class MainPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                string username Request.QueryStringQueryString["name"];
    
            WelcomeLabel.Text += ", " + username;
            }
        }
    }
    This bit of code has an error saying its expecting a semi-colon, anyone see the problem?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: strange error

    This line is invalid:
    Code:
    string username Request.QueryStringQueryString["name"];
    The error message is a bit misleading because it's telling you one thing when you actually need to do something else. That's not the IDE's fault though because it can't read your mind and know what you intended. The human eye can detect things like that though. I'm guessing that you meant to do this:
    Code:
    string username = Request.QueryStringQueryString["name"];
    so you were actually missing an assignment, but the compiler didn't know that. To it it seemed like you had two statements on one line and were missing a semicolon after this part:
    Code:
    string username
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width