Architectural Question

  • Thread starter Thread starter pantichd
  • Start date Start date
P

pantichd

Hello,

I'm using a Component Class object to represent a database table. This Data Access Object (DAO) has a connection object and data adapter object in it along with a bunch of methods that need to be there every time I create a new DAO to represent a db table.

Instead of having to code that "common" logic for each new class I'd like to create a base DAO, put the common logic there and inherit from it (instead of System.ComponentModel.Component) for each new DAO.

My current steps for creating a new DAO are:
1) Create a new Component Class object
2) Drag the database from the Server Explorer onto the design pane. This creates the connection object to the db.
3) Drag a table from the database in Server Explorer onto the design pane. This creates the data adapter object for that table.
4) Create all the common methods in the new DAO

Within an application, each DAO will have the exact same connection object so I'd like to include that in the base DAO.

Thinking along those lines, I created a new DAO (call it BaseDAO) and did steps 1, 2 & 4 from above. Then I created another DAO (ChildDAO) that inherits from the BaseDAO. I was hoping that I would then be able to just do step 3 from above for this new DAO.

When I try to bring up the designer for ChildDAO I get the following error:

The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file:

ChildDAO --- The base class 'LayerDataAccess.BaseDAO' could not be loaded. Ensure the assembly has been referenced or built if it is part of the project.

Both the BaseDAO and ChildDAO objects are in the same project. Does anyone have any ideas what I'm doing wrong?

Thanks in advance for any help.

David.
 
Eeeeesh. I'm sure you realize that "DAO" refers to legacy Microsoft Data
Access Objects. Not only has using that term scared off all the .Net guys
(hehe, j/k), but is it possible that referencing a class named "DAO" is
creating this problem?


Hello,

I'm using a Component Class object to represent a database table. This Data
Access Object (DAO) has a connection object and data adapter object in it
along with a bunch of methods that need to be there every time I create a
new DAO to represent a db table.

Instead of having to code that "common" logic for each new class I'd like to
create a base DAO, put the common logic there and inherit from it (instead
of System.ComponentModel.Component) for each new DAO.

My current steps for creating a new DAO are:
1) Create a new Component Class object
2) Drag the database from the Server Explorer onto the design pane. This
creates the connection object to the db.
3) Drag a table from the database in Server Explorer onto the design pane.
This creates the data adapter object for that table.
4) Create all the common methods in the new DAO

Within an application, each DAO will have the exact same connection object
so I'd like to include that in the base DAO.

Thinking along those lines, I created a new DAO (call it BaseDAO) and did
steps 1, 2 & 4 from above. Then I created another DAO (ChildDAO) that
inherits from the BaseDAO. I was hoping that I would then be able to just do
step 3 from above for this new DAO.

When I try to bring up the designer for ChildDAO I get the following error:

The designer could not be shown for this file because none of the classes
within it can be designed. The designer inspected the following classes in
the file:

ChildDAO --- The base class 'LayerDataAccess.BaseDAO' could not be loaded.
Ensure the assembly has been referenced or built if it is part of the
project.

Both the BaseDAO and ChildDAO objects are in the same project. Does anyone
have any ideas what I'm doing wrong?

Thanks in advance for any help.

David.
 
Good point.

Keep in mind what you're referring to is commonly known as a DAC, or Data
Access Component. DAO is definately going to throw some people off. No one
wants to help with Access problems :)

Anyway, it's hard to help with just theories & errors, and no code.

--ROBERT
 
Sorry to hear that my bad choice of terminology might confuse people.

How about if we start over and pretend I didn't call it DAO? I understand
what you're saying about this maybe confusing people but I really doubt that
the NAME I gave the object is what's causing the problem.
 
I see now how my terminology could confuse people. Sorry about that. My
first foray with MS programming has been .NET. My background is in Java and
I didn't realize that DAO had a special meaning to MS programmers.

I don't understand why you say "just theories & no errors, and no code" If
you look at my original message you'll see that the section beginning with
"When I try to bring up the designer for ChildDAO I get the following
error:" has the exact error I'm getting.

I'll be glad to provide anything else you need if I can get some help.Please
let me know.
 
Sorry for not being more specific (and sorry if I came off cocky).

What I need to know is how your ChildDAO class is inheriting BaseDAO. What
namespace are you in? Also, are you using CSC, Visual Studio, or something
else?

--ROBERT

P.S. DAC has been adopted by MS programmers primarily from Microsoft's label
MDAC for it's library of ODBC & OLEDB components.
 
Since my original choice of name could apparently be confusing to people let me rephrase my problem ...

Basically, I'm trying to extend a Component class object and I cannot open the child class in Designer mode. Here are the steps I'm going thru...

STEP #1 -- Create a Component Class and drag a database object (creating a connection) and table object (creating a data adapter) to the Designer.
STEP #2 -- Save this new Component class as BaseDAC (see Code Sample A below)
STEP #3 -- Create a new blank class file called ChildDAC
STEP #4 -- Add "Inherits BaseDAC" to the generated code for ChildDAC (see Code Sample B below)
STEP #5 -- Try to open Designer on ChildDAC object (see error message below)


CODE SAMPLE A
Public Class EmployeeDAC
Inherits System.ComponentModel.Component
Private OrderByValue As String
#Region " Component Designer generated code "
. . .
#End Region
Public Property OrderBy() As String
Get
Return OrderByValue
End Get
Set(ByVal Value As String)
If (OrderByValue Is Nothing Or OrderByValue = String.Empty) Then
OrderByValue = " ORDER BY "
End If
OrderByValue = OrderByValue & Value
End Set
End Property
. . .
End Class

CODE SAMPLE B
Public Class ChildDAC2
Inherits BaseDAC
End Class

ERROR MESSAGE
The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file:
ChildDAC --- The base class 'LayerDataAccess.BaseDAC' could not be loaded. Ensure the assembly has been referenced or built if it is part of the project.

NOTE: Both the BaseDAC and ChildDAC are in the same project and both compiled fine

Thanks in advance for any help.

David.
 
Robert,

I have another post in this thread that shows the example code of the child
class.

I'm writing VisualBasic using VisualStudio.NET

David
 
Problem solved...

Turns out I had to do a build before it could find the base class.

This has me puzzled, though. Being a MS-neophyte I just don't understand how the compiler knows that the class exists without me doing a build but the designer does NOT until I do a build.

Can someone explain that to me?

Thanks!
Hello,

I'm using a Component Class object to represent a database table. This Data Access Object (DAO) has a connection object and data adapter object in it along with a bunch of methods that need to be there every time I create a new DAO to represent a db table.

Instead of having to code that "common" logic for each new class I'd like to create a base DAO, put the common logic there and inherit from it (instead of System.ComponentModel.Component) for each new DAO.

My current steps for creating a new DAO are:
1) Create a new Component Class object
2) Drag the database from the Server Explorer onto the design pane. This creates the connection object to the db.
3) Drag a table from the database in Server Explorer onto the design pane. This creates the data adapter object for that table.
4) Create all the common methods in the new DAO

Within an application, each DAO will have the exact same connection object so I'd like to include that in the base DAO.

Thinking along those lines, I created a new DAO (call it BaseDAO) and did steps 1, 2 & 4 from above. Then I created another DAO (ChildDAO) that inherits from the BaseDAO. I was hoping that I would then be able to just do step 3 from above for this new DAO.

When I try to bring up the designer for ChildDAO I get the following error:

The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file:

ChildDAO --- The base class 'LayerDataAccess.BaseDAO' could not be loaded. Ensure the assembly has been referenced or built if it is part of the project.

Both the BaseDAO and ChildDAO objects are in the same project. Does anyone have any ideas what I'm doing wrong?

Thanks in advance for any help.

David.
 
I can't explain this particular issue, but consider that the compiler is the _compiler_. It has access to the source files. The designer is just a piece of code running inside of VS.NET. All it has access to is compiled code (which it is also able to examine via Reflection).

Different environments - different outcomes.

Problem solved...

Turns out I had to do a build before it could find the base class.

This has me puzzled, though. Being a MS-neophyte I just don't understand how the compiler knows that the class exists without me doing a build but the designer does NOT until I do a build.

Can someone explain that to me?

Thanks!
Hello,

I'm using a Component Class object to represent a database table. This Data Access Object (DAO) has a connection object and data adapter object in it along with a bunch of methods that need to be there every time I create a new DAO to represent a db table.

Instead of having to code that "common" logic for each new class I'd like to create a base DAO, put the common logic there and inherit from it (instead of System.ComponentModel.Component) for each new DAO.

My current steps for creating a new DAO are:
1) Create a new Component Class object
2) Drag the database from the Server Explorer onto the design pane. This creates the connection object to the db.
3) Drag a table from the database in Server Explorer onto the design pane. This creates the data adapter object for that table.
4) Create all the common methods in the new DAO

Within an application, each DAO will have the exact same connection object so I'd like to include that in the base DAO.

Thinking along those lines, I created a new DAO (call it BaseDAO) and did steps 1, 2 & 4 from above. Then I created another DAO (ChildDAO) that inherits from the BaseDAO. I was hoping that I would then be able to just do step 3 from above for this new DAO.

When I try to bring up the designer for ChildDAO I get the following error:

The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file:

ChildDAO --- The base class 'LayerDataAccess.BaseDAO' could not be loaded. Ensure the assembly has been referenced or built if it is part of the project.

Both the BaseDAO and ChildDAO objects are in the same project. Does anyone have any ideas what I'm doing wrong?

Thanks in advance for any help.

David.
 
When you Add a Reference to your project, select PROJECT and add a reference
to the project instead of the DLL. If you reference the DLL, then the
intellisense engine uses the .NET Manifest stored in the dll to resolve
classes & members (The designer uses intellisense for member resolution).
The manifest is created when the DLL is built _successfully_.

Alternatively, if you add a reference to the project, the intellisense
engine uses an internal database for class/member resolution (As can be seen
in the CLASS VIEW window). Also, by referencing the project rather than a
DLL, VS can determine dependancies, and know to build your base class'
project before your inheriting class' project.

If this is all one project (I haven't looked at the source), then it's
probably some condition in the intellisense engine telling it to reference
the DLL rather than it's internal database. In that case, the compiler will
recognize the base class during a build, but if it doesn't build
successfully, no updated manifest is created, and Visual Studio is still
unaware that the base class exists.

I hope I've helped.

--ROBERT


Problem solved...

Turns out I had to do a build before it could find the base class.

This has me puzzled, though. Being a MS-neophyte I just don't understand how
the compiler knows that the class exists without me doing a build but the
designer does NOT until I do a build.

Can someone explain that to me?

Thanks!
Hello,

I'm using a Component Class object to represent a database table. This Data
Access Object (DAO) has a connection object and data adapter object in it
along with a bunch of methods that need to be there every time I create a
new DAO to represent a db table.

Instead of having to code that "common" logic for each new class I'd like to
create a base DAO, put the common logic there and inherit from it (instead
of System.ComponentModel.Component) for each new DAO.

My current steps for creating a new DAO are:
1) Create a new Component Class object
2) Drag the database from the Server Explorer onto the design pane. This
creates the connection object to the db.
3) Drag a table from the database in Server Explorer onto the design pane.
This creates the data adapter object for that table.
4) Create all the common methods in the new DAO

Within an application, each DAO will have the exact same connection object
so I'd like to include that in the base DAO.

Thinking along those lines, I created a new DAO (call it BaseDAO) and did
steps 1, 2 & 4 from above. Then I created another DAO (ChildDAO) that
inherits from the BaseDAO. I was hoping that I would then be able to just do
step 3 from above for this new DAO.

When I try to bring up the designer for ChildDAO I get the following error:

The designer could not be shown for this file because none of the classes
within it can be designed. The designer inspected the following classes in
the file:

ChildDAO --- The base class 'LayerDataAccess.BaseDAO' could not be loaded.
Ensure the assembly has been referenced or built if it is part of the
project.

Both the BaseDAO and ChildDAO objects are in the same project. Does anyone
have any ideas what I'm doing wrong?

Thanks in advance for any help.

David.
 
Back
Top