You must Sign In to post a response.
  • Category: .NET

    Pls tell me ,how can solve dis below error,the below statement is a c# statement.

    C# STATEMENT: foreach (DataColumn tblList in catDB.Tables)

    ERROR MESSAGE: A local variable named 'tblList' cannot be declared in this scope because it would give a different meaning to 'tblList', which is already used in a 'parent or current' scope to denote something else
  • #584043
    Please change the name of local variable "tblList" as this may already define. Change the line as

    foreach (DataColumn tblList1 in catDB.Tables)

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #584050

    this is the same issue , check wether you used the variable in the previous lines of code .

    As per C# specification the scope of a variable is within a block. If you used this variable in the previous lines you will get this error if this is inside the blocks you can use the same varibale n number of times,

    Check your previous lines of code.


  • #584115
    It seems lika a object named tblList has already been declared in the same scope. So, you cannot declare another object with the same name. To resolve the issue you can use another name for the object. Please check the following code:

    foreach (DataColumn tblListNew in catDB.Tables

    Thanks & Regards
    Paritosh Mohapatra
    Microsoft MVP (ASP.Net/IIS)
    DotNetSpider MVM

  • #584165
    try this code

    foreach (DataColumn NewtblList in catDB.Tables)
    //your code

    hope this will help you

  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.