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 sColn in tblList .Columns)
    {

    ERROR MESSAGE: A local variable named 'sColn' cannot be declared in this scope because it would give a different meaning to 'sColn', which is already used in a 'parent or current' scope to denote something else
  • #583360
    The error suggest that a variable named sColn has already been defined. So you should use another variable name instead of sColn.

    Please check the following code:


    foreach (DataColumn sColn1 in tblList.Columns)


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

  • #583363
    yes this the vriable has already been defind some where else in the code and we cannot re use it again for some other prupose. You can change the variable name over here.

  • #583368
    Please change the variable name as


    foreach (DataColumn sColn1 in tblList .Columns)

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #583374
    Hi


    foreach (DataColumn sColn1 in tblList.Columns)


    < i > Regards </i >
    < font color="Brown" > Angad Yadav </font >

  • #583403
    try this code



    foreach (DataColumn sColnNew in tblList .Columns)
    {
    //your code
    }


  • 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.