Forms over Data Video Series #2 is Live!

Forms over Data Video Series #2 is Live!

  • Comments 49

I just uploaded more videos to Microsoft Downloads! I wanted to post the direct links here and the matching code downloads for all of you immediately even though MSDN will be creating a pretty landing page like this one for them this week, probably tomorrow or Wednesday. (I'll update this post when that's up).

Download the Forms over Data Video Series #2 and the associated code now!

Leave a Comment
  • Please add 8 and 1 and type the answer here:
  • Post
  • Hi Beth,

    I watched your video series and got a few questions:

    - in general you create a new Dataset for each new form; is that important for separating tables or can you use one 'giant' dataset for the application?

    - are there major differences when using an MSAccess back-end database instead of the SQLServer (Express) ones?

    - how can you display several fields from a foreign key related record in a datagridview; e.g. showing product description, standard price, units/pkg, etc. in ao order details grid; when I try to do that, I end up either with a non-updatable grid (error at save) or troubles at starting the screen (incorrect relations for the several Fills).

  • Hi Maarten,

    You could go either way for small applications however you need to watch out how much data you are loading into the DataSets because as data grows in your database you can run into scalability problems. Make sure you always use parameterized queries to select only the data you need.

    However, if you have a lot of different forms that need to use different parts of the database, or you need to model your DataSets more like Views or Entities into your data (where they may not map one-to-one with your database tables) then it's better to create a multiple datasets, not necessarily one for each form, but one for each "View" of the data. Or you may choose to create a separate DataSet because of different business rules (which you can put in the partial class of the DataSet so you can reuse rules across forms).

    Regarding SQL-Server vs. Access. SQL-Server is a good route to take if you are going to need to scale to more users in the future since you can take a SQL-Express MDF file and attach it to an instance of SQL Server Standard or Enterprise -- so it gives you an easy upgrade path. Access, however is much easier to deploy since it is just a file, but only cannot handle as many users and is not as secure as SQL-Server. There are many other features that SQL-Express gives you for free like Reporting and Analysis services.

    Regarding your last question you probably want to check out this video:



  • Hi Beth,

    you did a great job. These Videos really help to understand some things.

    I've just one problem with the reportviewer. I can't create a new report. When I'm clicking on the text "Design a new report" nothing happens. May I need to set some other options first or what could be the fault.

    I hope you can help me.

  • Hi Steven,

    I'm not sure what's wrong there. You can try adding a report by right-clicking on your project, select Add New Item and then choose Report.



  • Hi Beth,

    I certainly watched your video "5CreatingLookupLists.wmv" and tried to use it in my application with an MSAccess database, that's why.

    1. I got rather confused by the foreign key relation set-up in your database (orders-order details), but it appeared to be 'relation only'. After changing that in my database (with sets of songs), the first thing worked (details for order and grid for the details), without errors. What is the exact difference (in application handling) for having relation only or relation and foreign key?

    2. After that I created a lookup (comparable to the productlookup), dragged a BindingSource for it to the form, added a column/combobox to the grid and arraned all settings. But, consequently the compiler gives the error:

    Error 1 withEvents variable 'Set_songsTableAdapter' conflicts with a member implicitly declared for withEvents variable 'SongsTableAdapter' in class 'Sets'.

    What can be the cause for that?

  • Hi Maarten,

    The difference between a Relation Only and a Foreign Key Constraint is that if it's a FK then the DataSet will enforce the integrity of the rows so that you cannot add a child row without a parent row already existing. That would mean that you would need to call EndEdit on the parent's BindingSource before you could add any child rows. You would also need to fill the DataSet in Parent then Child order.

    Your second question sounds like the code generation for the DataSet got out of sync. Try recreating the DataSet and TableAdapter to see if that resolves the problem.



  • Hi Beth,

    Well, I tried to recreate DataSet and TableAdapter, but withut success. Only after changing all relations (within the database) to relation only, and deleting the relation between Songs and SetSongs (the foreign key) the application started to work as designed ?!? It is all rather confusing !

    Another question:

    I am trying to create a form with ContactPersons, that are realted to Companies. In the main tab on the form a DataGridView shows persons, selected on a part of their name, including Name and City of the Company (builded as in your example).

    Now I am trying to create on the detail tab a form with all details and the possibility to change the Company. To limit the load of Company records, the TableAdapter is filled by a query according to the selected persons. When I go to the detail tab, the Company BindingSource appears to get stuck on the last Company shown in the datagrid.

    How can I sync main and detail tab with regard to this Company bindingsource and how do I get easily a combobox to be able to change the Company reference ? Do you have an example for that?



  • Hi Maarten,

    Take a look at this sample application built on the Northwind database:

    It's an application I built for this post:

    But it demonstrates how to create a search form and then pull up the details with lookup lists.



  • Beth:

    Thank you for the whole video series. It's a very useful learning tool.

    Now, I need some advice. How could I share a dataset between forms?

    Better I tell you my application design.

    I use to have forms, with a datagridview and search capabilities (a set of diferent posibilities). That's fine. But I don't do the edition (delete, inset & update) functions in the same form. Instead, I open a dialog form, with the current row from my datagridview to edit, delete or insert a new one, in a input data fashion dialog.

    Which would be an easy way to implement the kind of functionatilly I've described ?

    Thanks in advance

    Jorge (far far away... from Buenos Aires)

  • Beth:

    I'd found "How to: Share Bound Data Across Forms Using the BindingSource Component" in msdn, but it's for .NET Framework 3.0 and I'm currently in 2.0

    I think I cannot implement the BindingComplete event..

  • Hi Jorge,

    The BindingComplete event on the BindingSorce is available in .NET 2.0 Framework.

    To share the actual DataSet between forms there's many ways you can do it. For instance, you can either expose the Dataset as a public property in a public module (shared class) that handles all your data access needs or you can expose the Dataset from a main form to any child form using a public property. Then in the Load of your forms you would use the shared dataset by setting it to the DataSource property of your Bindingsource.

    But remember, you can still create separate references of the actual DataSets on the forms but only allow Add, Edit and Delete individually (you can remove the binding navigator buttons by selecting them in the toolstrip in the designer and hitting the delete key). The tables in the Database are still the same and will be updated properly.



  • i have a datetime field in my table, it does not allwo nulls. i have a form on which i draggeddrop the data set to create automatic binding and navigation. The problem is that when i add new row the date time control shows the default time which is Now. But this time is not getting set in my current row when i try to save the table. if i click and select one date in the control it allows me to save to table. Otherwise it throws the exception of does not allow null for this column. I hope u understand my problem. Please let me know how can i solve this.

  • follow up on Jorge's question.   Is there any examples anywhere on the web for keeping a parent to child table connection across 2 forms.  Just like in Beth's video of "How Do I: Create a One-to-Many Data Entry Form?"  Expect move the related Orders datagridview to a new form and still keep the connection.  Example have both forms open and use the bindingnavigator on the first form to scroll through the records and still have the orders form correspond to the selected record on the first or main form.

  • Hi Shiram,

    You may want to use a textbox and set the formatting as date instead. There are issues with the DateTime control and nulls. The other option is to enable the "ShowCheckbox" property. When this is checked then the value is pushed to the datasource. If it is unchecked then the value is NULL.



  • Hi GISPS,

    Sharing the connection isn't what you're looking for in this case, I think what you want is to share the DataSet and the BindingSources so that both forms can access them. I've never created a form like that but you can try exposing the child BindingSource as a public property on your first form and then binding your grid on the second form to that.



Page 1 of 4 (49 items) 1234