Data Sources window and data access library

F

Flomo Togba Kwele

I am trying to create datasets in a data access class library and use
them in the presentation layer.

To create the dataset, I select the data access class library project in
the Solution Explorer, right-click, Add New and drag a table from the
Server Explorer onto the designer surface. I can see the dataset in the
Solution Explorer and the Class View for the data access class library.
I then rebuild that project.

Then I open a form designer in the presentation layer, open the Data
Sources window, expand the data access class library project in the Data
Sources window, and the newly created dataset is NOT THERE!

What am I missing?

TIA
 
R

RobinS

Flomo Togba Kwele said:
I am trying to create datasets in a data access class library and use
them in the presentation layer.

To create the dataset, I select the data access class library project in
the Solution Explorer, right-click, Add New and drag a table from the
Server Explorer onto the designer surface. I can see the dataset in the
Solution Explorer and the Class View for the data access class library.
I then rebuild that project.

Then I open a form designer in the presentation layer, open the Data
Sources window, expand the data access class library project in the Data
Sources window, and the newly created dataset is NOT THERE!

What am I missing?

TIA

It's in the data access layer. If your layers are in separate projects, you
need to create the data source in the right layer.

Robin S.
 
F

Flomo Togba Kwele

That's what I said, Robin, I did create it in the data access layer.
However, it does not show up in that layer in the Data Sources window.
 
W

WenYuan Wang

Hi Flomo,

I'm not sure if I have understand the issue completely. I just want to
confirm some information. I understand that you have two
projects(ClassLibrary Project for Data Access Layer, WinForm Project for
Presentation Layer). You have created Typed DataSet in ClassLibrary
Project. But you cannot see it in the WinForm Project. Have I misundstood
anything here?

If this is true, I'm afraid this is by design. The Typed DatSet could only
be seen in ClassLibrary Project which it be created from. We cann't get it
from the other projects, even through they are in the same solution.

Please don't hesitate to correct me if I have misunderstood anything here.
Have a great day!
Sincerely
Wen Yuan
 
F

Flomo Togba Kwele

Thanks for the reply, Wen Yuan.

When I have a blank form displayed in the WinForm project and the Data
Sources window open, I do see the Class Library Project for Data Access
Layer, but the newly created dataset does not show up there.

This view in the Data Source window is consistent with what appears to
be visible when I click on the WinForm Project in the Solution Explorer.
However, when I click on the Data Access Layer in the Solution Explorer,
the view in the Data Source window changes, and I can see the newly
added dataset.

But when I expand the dataset and drag the datatable to the form's
designer surface, the IDE will not allow this - it displays a black
circle with a diagnol line through it.
 
R

RobinS

I thought you said it didn't show up in the Data Source window when you're
accessing a form in the Presentation (UI) layer.

Robin S.
--------------------------
 
R

RobinS

That's because they are in different projects. You need to add the data
source to your Presentation layer.

Robin S.
--------------------------------------
 
F

Flomo Togba Kwele

Thanks for replying, Robin.

You are right - I was confused.

When the Solution Explorer is set on the Presentation layer project, I
can see the Data Access layer in the Data Sources window, but the newly
added dataset does not appear in that list.

However, if I select the Data Access layer project in the Solution
Explorer, this changes the display in the Data Sources window. I can see
the newly added dataset. But dragging is disabled when I try to drag the
datatable within the dataset in the Data Sources window onto the
designer surface.

Is this by design? I am not allowed to segregate my data access code
from the presentation layer?
 
R

RobinS

Yes, it's by design.

I'm not sure how to segregate the data access code from the UI when you're
using strongly typed data sets.

You could set a reference in your UI that points at the data access layer,
and then call the DAL to load your strongly typed dataset. That's what I
would try.

I use business objects rather than strongly typed datasets, but have mucked
around with them some, which is why I knew the answer to your first
question. :)

Robin S.
----------------------------------
 
F

Flomo Togba Kwele

Robin,

It's hard for me to believe this is intended behavior, especially since
Brian Noyes, in 'Data Binding with Windows Forms 2.0", stressed
segregating the two layers. But he didn't explain how to do it.

I've been playing a little with objects in addition to datasets - OPF3.
It's interesting.
 
R

RobinS

Flomo Togba Kwele said:
Robin,

It's hard for me to believe this is intended behavior, especially since
Brian Noyes, in 'Data Binding with Windows Forms 2.0", stressed
segregating the two layers. But he didn't explain how to do it.

I've been playing a little with objects in addition to datasets - OPF3.
It's interesting.

Well, I have one friend who's an MVP who does all her stuff with business
objects, and another friend who's an MVP who does all her stuff with
strongly typed datasets. (You'd think these people could agree on a
methodology. ;-)

I thought about asking how she's using her datasets in her UI layer, but
I'm sure that she is defining them in the business layer, and then setting
a reference in her UI layer. It makes sense to me. She might even be
passing them back to her UI layer from her business layer. If you want,
I'll ask her. I want to know, anyway.

Wasn't that Brian Noyes book a great book? One of my favorites. I had a lot
of trouble figuring out how to bind a list of objects to a DataGridView and
then add update capabilities, but after a lot of angst, I finally got it to
work. It turned out if you bind a list of objects to a DataGridView, and
the constructor of your object is not public, the DGV will not enable the
Add option. I found that little nugget of info in Chris Sells' Windows
Forms 2.0 Programming book, luckily *before* I pulled all of my hair out.

Robin S.
 
W

WenYuan Wang

Hi Flomo,

Many thanks for Robin's reply.

Yes, Flomo. I'm afraid this is by design. They are in different projects.
We are indeed sorry for any inconvenience this may have caused.

By the way, if you really have concern on this, we suggest you may submit
this feedback to our product feedback center. This feature maybe supported
in the next version of Visual Studio.
http://connect.microsoft.com/site/sitehome.aspx?SiteID=210

Please feel free to let me know if there is anything we can help with.
Thanks.
Best regards,
Wen Yuan
 
F

Flomo Togba Kwele

I could not accept the advice I received from all of you, although I am
very appreciative for the responses.

I wrote Brian Noyes and he was so kind to write back. He said, as he did
in his book, "Data Binding with Windows Forms 2.0", that you can have a
dataset in one layer and refer to it in another, thereby separting data
from presentation.

In the data layer project, right-click and add a new dataset. Rebuild
this data layer project.

Now go to your presentation layer and bring up a Designer tab (a Form or
UserControl). In the Data Sources window, Add a New Data Source, or get
there via the Data menu item. Choose Object as your Data Source Type.
Navigate to the Data Layer project and locate the dataset you just
created.

That should do it. Again, thanks so much to Brian Noyes for this tip.
 
W

WenYuan Wang

Thanks Flomo, Robin, and Brian Noyes.

This is really helpful. I'm apologize that I can't figure this out in my
reply. I think this is because we referred this dataset to another layer as
Object Data Source, so we can access it. It is really a great solution.
Greatly appreciate you post back the solution.
I'm sure there must be many people will get benefit from this.
For people who want to access the typed dataset from another layer, we can
add the dataset in one layer and refer to it in another layer by Object
Data Source.

Thanks again for your feedback.
Best regards,
Wen Yuan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top