Click here to Skip to main content
15,845,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
A local variable named 'frmMultiPlanReport' cannot be declared in this scope because it would give a different meaning to 'frmMultiPlanReport', which is already used in a 'parent or current' scope to denote something else

frmMultiPlanReport frmMultiPlanReport = this;
frmMultiPlanReport.SqlQry = str5;
Sergey Alexandrovich Kryukov 30-May-15 6:17am    
"I don't understand" is not informative and not yet a question.

One line is not enough for us to say: "That's it! Right there! See?" with an error like this, because the problem it's reporting is that a variable already exists in the same scope which has the same name - and it can't cope with that!
It's like children: in a classroom it's not unusual to have two or more children with the same first name ("Joe" for example), and most times this can be resolved by using the family name as well: "Joe Brown" and "Joe Smith" removes the confusion as to which child is being referred to.
But within a family you can't do that: if you called all your male children "Joe" then you would confuse the issue every time you tried to get a specific one of them to do something.

C# is the same about scope: you can't have two variables with the same name.
You have done something like this:
public class MyClass
    public void MyMethod()
        MyClass MyClass = new MyClass();
        while (true)
            MyClass MyClass = new MyClass();
And the error is being reported on the second definition of the MyClass variable. Just change it's name, and you'll be fine.
Share this answer
Dilan Shaminda 30-May-15 3:41am    
+5 :-)
It says u have declared 'frmMultiPlanReport' twice inside the same scope.That definition is conflicting with the one just outside. Check this post.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900