Solved

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

Posted on 2007-03-23
5
516 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
ethoths earned 500 total points
ID: 18781652
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
ID: 18782020
check and see if any of these variables are commented out for debugging purposes
0
 

Author Comment

by:rschnell11
ID: 18782398
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
ID: 18782494
can you check in IIS if your app is running under asp.net 2.0 and Not 1.1
0
 

Author Comment

by:rschnell11
ID: 18782605
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…
Simple Linear Regression

726 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