Solved

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

Posted on 2007-03-23
5
511 Views
Last Modified: 2008-02-20
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
Comment
Question by:rschnell11
  • 2
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
ethoths earned 500 total points
Comment Utility
Are you missing the partial class. Vb.Net 2.0 puts all the auto generated code in a seperate designer class.
0
 
LVL 27

Expert Comment

by:Sammy
Comment Utility
check and see if any of these variables are commented out for debugging purposes
0
 

Author Comment

by:rschnell11
Comment Utility
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
 
LVL 27

Expert Comment

by:Sammy
Comment Utility
can you check in IIS if your app is running under asp.net 2.0 and Not 1.1
0
 

Author Comment

by:rschnell11
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This is about my first experience with programming Arduino.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now