[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 531
  • Last Modified:

VS2005 VB.NET WEB - variables not declared that are.

VS2005 SP1 VB.NET WEB Application

I have an application which is in devlopment and had no problem until today.  Suddenly variables that are clearlr declared are flagged  as not declared and I can no longer build the project. It appears ANY new code i add to the project sufferes this fate. So I will pick a simple example: In code behind I have.

    Protected Function LoadUsers(ByVal CaseID As String) As Boolean
        Dim strSelect As String = "SELECT USERNAME  FROM CASEUSERS WHERE (CaseID =" & Trim(CaseID) & ") ORDER BY USERNAME ASC"
        With dsCaseU
            .SelectCommand = strSelect
            .DataBind()
        End With
        dListUsers.DataBind()
    End Function

In ASPX I have

    <asp:SqlDataSource ID="dsCaseU" runat="server" ConnectionString="<%$ ConnectionStrings:CMSConnectionString %>"
                SelectCommand="SELECT DISTINCT USERNAME  FROM CaseUsers   ORDER BY USERNAME ASC">
            </asp:SqlDataSource>  

And doing a solution build I get:

E:\CMS.NET\CMSCaseBlog.aspx.vb(63,0): error BC30451: Name 'dsCaseU' is not declared.
E:\CMS.NET\CMSCaseBlog.aspx.vb(67,0): error BC30451: Name 'dListUsers' is not declared.
Validation Complete
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

Note these names are not highlighted in blue by intellisense.

Some background. The problem started this morning and I had the same as above except these variables WERE highlighted in blue in the code behind as not declared .

Out of frustration I de-installed VS2005 completely and re-installed it. I also upgraded to SP1. Now I get this result and still cannot move forward.

Am I missing somethning stupid?



0
rschnell11
Asked:
rschnell11
  • 2
  • 2
1 Solution
 
ethothsCommented:
Are you missing the partial class. Vb.Net 2.0 puts all the auto generated code in a seperate designer class.
0
 
Sammy AgeilCommented:
check and see if any of these variables are commented out for debugging purposes
0
 
rschnell11Author Commented:
1. check and see if any of these variables are commented out for debugging purposes

It happens to all variables that are added now, this is not just a sample. Existing ones are Ok.  for example if I add the folloing to the end of the aspx and add another line to the vb code, now SQLdataSource1 is not declared. Any change results in variables in the code behind not declared.
CODE BEHIND  CHANGE
        dListUsers.DataBind()
        SqlDataSource1.DataBind()
:
ASPX CHANGE
              <asp:SqlDataSource ID="dsUsers" runat="server" ConnectionString="<%$ ConnectionStrings:CMSConnectionString %>"
                SelectCommand="SELECT USERNAME  FROM USERS ORDER BY USERNAME ASC">
            </asp:SqlDataSource>
           
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CMSConnectionString %>"
                SelectCommand="SELECT USERNAME  FROM USERS ORDER BY USERNAME ASC">
            </asp:SqlDataSource>
           
        </div>
    </form>
</body>
</html>


2. Mising partial class.
All the code is encompassed within the partial class
Partial Class AddNote
    Inherits System.Web.UI.Page
      .
      .
      .
End Class
0
 
Sammy AgeilCommented:
can you check in IIS if your app is running under asp.net 2.0 and Not 1.1
0
 
rschnell11Author Commented:
Sorry I should have satid,its NET 2.0.
However, "ethoths" is correct. I just looked up the details oh how partial classes work. So realising the implications, I changed the name of the partial class to something I am absolutely sure is unique ... and now its all working. I still don't understand why it stopped working today as I only added the three or four lines of code and only to this class and it was just working before that. However, I guess if there is some other codebehind partilal class with a duplicate name, I understand now that there may well be a conflict, looking in the wrong aspx perhaps?

The main thing is that its working again. Thank you all.

So whilst I am not sure how the problem occured , partial class naming is the source of the problem.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now