title: How to Loop through LINQ results (VB.NET)
body: <p>I've got some code to try and loop through LINQ results, but it doesn't seem to be working.</p>
  
  <p>HERE'S THE CODE</p>
  
  <pre><code>    Public Sub ProcessRequest(ByVal context As System.Web.HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
          ''# the page contenttype is plain text'
          HttpContext.Current.Response.ContentType = "text/plain"
  
          ''# store the querystring as a variable'
          Dim qs As Nullable(Of Integer) = Integer.TryParse(HttpContext.Current.Request.QueryString("ID"), Nothing)
  
          ''# use the RegionsDataContext'
          Using RegionDC As New DAL.RegionsDataContext
  
              ''# create a (q)uery variable'
              Dim q As Object
  
              ''# if the querystring PID is not blank'
              ''# then we want to return results based on  the PID'
              If Not qs Is Nothing Then
                  ''# that fit within the Parent ID'
                  q = (From r In RegionDC.bt_Regions _
                          Where r.PID = qs _
                         Select r.Region).ToArray
  
                  ''# now we loop through the array'
                  ''# and write out the ressults'
                  For Each item As DAL.bt_Region In q
                      HttpContext.Current.Response.Write(item.Region &amp; vbCrLf)
                  Next
  
              End If
  
  
  
          End Using
      End Sub
  </code></pre>
  
  <p>HERE'S THE ERROR</p>
  
  <blockquote>
    <p>Public member 'Region' on type
    'String' not found. Description: An
    unhandled exception occurred during
    the execution of the current web
    request. Please review the stack trace
    for more information about the error
    and where it originated in the code.</p>
    
    <p>Exception Details:
    System.MissingMemberException: Public
    member 'Region' on type 'String' not
    found.</p>
    
    <p>Source Error:</p>
    
    <p>Line 33:                     ' and
    write out the ressults Line 34:<br>
    For Each item In q Line 35:<br>
    HttpContext.Current.Response.Write(item.Region
    &amp; vbCrLf) Line 36:<br>
    Next Line 37: </p>
    
    <p>Source File:
    E:\Projects\businesstrader\App_Code\Handlers\RegionsAutoComplete.vb
    Line: 35</p>
    
    <p>Stack Trace:</p>
    
    <p>[MissingMemberException: Public member
    'Region' on type 'String' not found.] 
    Microsoft.VisualBasic.CompilerServices.Container.GetMembers(String&amp;
    MemberName, Boolean ReportErrors)
    +509081    Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object
    Instance, Type Type, String
    MemberName, Object[] Arguments,
    String[] ArgumentNames, Type[]
    TypeArguments, Boolean[] CopyBack)
    +222    BT.Handlers.RegionsAutoComplete.ProcessRequest(HttpContext
    context) in
    E:\Projects\businesstrader\App_Code\Handlers\RegionsAutoComplete.vb:35
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    +181    System.Web.HttpApplication.ExecuteStep(IExecutionStep
    step, Boolean&amp; completedSynchronously)
    +75</p>
  </blockquote>
  
  <p>Can anyone tell me what I'm doing wrong?</p>