all groups > dotnet windows forms databinding > september 2007 >
You're in the

dotnet windows forms databinding

group:

DataSet Usage


DataSet Usage Tom Woods
9/17/2007 1:57:47 PM
dotnet windows forms databinding: I've been struggling with the best way to use a DataSet, Bindings and
Adapters in the application I'm laying out. To start, I'm new with
DataSet's and MS SQL. I'll start by describing what my goals are:

I have a form that will have a list (grid) of items from Orders. This list
will be docked to the left side of my form. It will contain all orders of
the day. I want to allow the user to create/view multiple orders using MDI.
So when they click on an item in the
list/grid, it will update the focused order form. If they create a new
order, it will create a new Order from (child mdi). They could even be
viewing multiple orders.

From the standpoint of design. What is the best way to setup my DataSet?
Should I have multiple - one for the list and one for each order form? Or,
can just one be used?

The listing of the orders is staight forward, however, how to manage two or
more records being desplayed is a little more confusing.

When it gets to TableAdapters, can you only have one? I thought about
having the list/grid use one Fill method and the forms use another. Can
this be done?

I would like the fields on the MDI Child forms to be bound - if possible.

As you can see, I'm a little lost. Can anyone shed a little light?

TIA,

Tom




Re: DataSet Usage Jim Rand
9/18/2007 2:54:31 PM
I'd create a separate dataset for each form as well as for the list grid
form.

The list of orders might have a select statement like "SELECT OrderID,
OrderDate, ...<more fields to display> FROM ...

Each child form would have it's own dataset. The form constructor would
have OrderID passed as a parameter. In the form load event fill the the
order info dataset using the OrderID as parameter as in SELECT ... FROM
Order ... WHERE OrderID = @OrderID.

In the list grid form, I'd have it raise an event with the OrderID in the
event args. I'd have the MDI form listen for those events so that the MDI
form can open a child Order form.

After adding a new order, make sure you manually add the row to the grid
list, or, refresh the grid list from the database.

As an aside, I'd first work with the table adapters and related wizards
until I got to the point they destroyed the project. Then, I'd move back to
the VS 2003 approach using a component containing multiple data adapters.
Finally, I'd chuck the whole data adapter wizard, bite the bullet, and write
my own wizards either in MS Access or .NET to generate data adapter code.



[quoted text, click to view]

Re: DataSet Usage Tom Woods
9/18/2007 3:19:49 PM
Thank you for your feedback!

I actually have created two small projects to determine the best way to
achive my goals. In one example, I'm using the BindingSource to tie the
list/grid and some actual bound fields on a form. However, I don't know how
to get the desiner to see the BindingSource from another form when trying to
add additional fields on a new form.

Are you familier with a way to have Form B see Form A's BindingSource?

Thanks,
Tom


[quoted text, click to view]

Re: DataSet Usage Jim Rand
9/19/2007 7:28:04 AM
I've got a shared dataset for lookup tables. For example, assuming your
orders have order detail rows that reference inventory, the dataset
dsLookupTbls would contain an inventory table.

On the order form, you would drag a dsLookupTbls component onto the form
designer. Then you would drag a binding source onto the form designer.
During the form load, you would hot swap the datasource as in

bsInventory.DataSource = Helpers.LookupTblSingleton.Instance.dsLookupTbls;

Be careful of binding sources. There is a nasty bug that Microsoft has been
trying to fix for over a 1 1/2 years. See KB932491.

Jim

[quoted text, click to view]

Re: DataSet Usage Tom Woods
9/19/2007 7:43:15 AM
Jim, thanks for the explaination...

I looked up KB932491 and it looks like it has been resolved. Take a look:
http://support.microsoft.com/kb/932491/en-us

Thanks again,
Tom


[quoted text, click to view]

AddThis Social Bookmark Button