Forms Over Data Video Series - Two More Videos Released

Forms Over Data Video Series - Two More Videos Released

  • Comments 90

I just released two more videos (#15, #16) in the Forms Over Data video series. One is on understanding data binding and how it works from database all the way to the controls you see on forms. We talk about the relationship between the TableAdapter, the BindingSource and the DataSet and I show how to work with data in your code.

The second one explains how to update related data tables like I explained in this post. This video doesn't go into how to set up the transactions but you can read about how to do that here. I've also attached the code from the videos here.

Enjoy!

Attachment: FormsOverDataCode15-16.zip
Leave a Comment
  • Please add 7 and 6 and type the answer here:
  • Post
  • Hi beth,

    Thanks heaps for sharing your ideas through video series, really appreciate.

    I have just one quick question reagarding Databinding over windows forms. I have two tables called Cust_Num and Cust_Addrss. Now I want to show customer's address details using his/her contact number. But I want to use two different forms. And dont know how to set relationship between these two forms using button click event.

    Hope I have make my self simple.

    Please let me know. Thanks again.

    Cheers,

    Dev

  • Beth,

    Thank you ever so much for these videos, I know you have had these up for a while, but I have now hit the Data Access segment of my MCAD course, and your videos have proven priceless.

    I have given you praise on my blog! Thank you for taking the time out to produce these.

    Thanks again,

    Rob

  • Hi Eva,

    Check out this blog post http://blogs.msdn.com/bethmassi/archive/2007/05/29/working-with-a-local-data-file-in-vs.aspx and this video http://msdn2.microsoft.com/en-us/vbasic/bb643822.aspx

    HTH,

    -B

  • Hi Dev,

    There are a couple ways to do this. But if the data is already in your dataset then all you have to do is pass the dataset reference to the detail form and set that as the Datasource property of the BindingSource there. The easiest thing to do would to design your detail form like normal using the designer against the same dataset which will set up the BindingSource on the detail form. Then on the detail form's constructor you'd pass the DataSet and the primary key of the row you're looking for so that you can set the position. Something like:

    Sub New(ByVal ds As DataSet, ByVal id As Integer)

           ' This call is required by the Windows Form Designer.

           InitializeComponent()

           ' Add any initialization after the InitializeComponent() call.

           Me.MyBindingSource.DataSource = ds

           Me.MyBindingSource.Filter = "ContactID = " & id.ToString

       End Sub

    Doing this will automatically update the same exact row references on the master form so if you are displaying the data there, it will update there also.

    The other way to do it would be if you do not have the data for the address contained on the master form, but instead it is still in the database. In that case you'll want to split your DataTables into separate DataSets and then add a parameterized query on the TableAdapter for the address table so that you can pass the contact key into the database to return the results for just that contact.

    HTH,

    -B

  • Hi Beth,

    EXCELLENT vids! clear & concise.  It realy is exactly what I needed..jus wish I found this earlier when I was reading article after article!

    Could you please tell me, in the method to call a modal dialog box for editing purposes, is there a better mthod of sending the Primary Key value through other than:

    "DataGridView1.SelectedRows.Item(0).Cells(0).Value" ?

    Thanx again!

  • Hi Shalan,

    You'll want to watch video #15: http://msdn2.microsoft.com/en-us/vbasic/bb725824.aspx

    This video walks though techniques on using data in your code and accessing the current row using the BindingSource object.

    Basically you can cast the .Current property of the BindingSource to your typed DataRow and access the fields as properties:

    Dim row As MyDataSet.MyDataRow = CType(CType(Me.MyBindingSource.Current, DataRowView).Row, MyDataSet.MyDataRow)

    Dim id As Integer = row.MyID

    HTH,

    -B

  • Hi Beth,

    thanx for that. In fact, I just read your article "Using Data Across Mutiple Windows Forms" and it put alot of things into perspective!

    I do have 2 questions tho I'm hoping you could answer please:

    1) I have in my database table (Table1), a foreign key column to another table (Table2) that just has a primary key column and a string column.  My datagridview is bound to a dataset for Table1, and obvoiusly shows my Foreign Key integer vaues in the last column.  How can I instead show the associated string value in Table2 in my datagridview?

    2)  I know and more-or-less understand how the BindingSource.Filter method works (I'm reading up currently on MSDN library).  But how can I take the result for say an integer count based on a filter and let that reflect in a label?

    thanks & kind regards

  • Hi Shalan,

    Please take a look at the rest of the Forms over Data videos, specifically #5 on creating lookup lists: http://msdn2.microsoft.com/en-us/vbasic/bb643829.aspx

    Regarding your second question, you can check the BindingSource.Count property once the filter is applied to obtain the number of filtered rows.

    You may also want to check out the VB support forums for more info: http://forums.microsoft.com/msdn/default.aspx?forumgroupid=10&siteid=1

    Cheers,

    -B

  • Thanx beth,

    just downloaded all the videos, and having a look at them now. No doubt they will prov to be very helpful!  and congratualtions on releasing such informative (and free!) training vids!

    regards

  • sir,i hav used a binding navigator.binded to a datasource.wen it is navigating i want to fill the controls(textboxes,combobox,etc) with data.also i want to fill a datagridview with the data from some another table based on one textbox value(say customerid).wen it is navigating,obviously the datagridview's data also should change acccording to the customerid textbox's value.how can i do this thanks.

  • Hi Liju,

    I cover exactly how to do all that in these videos: http://msdn2.microsoft.com/en-us/vbasic/bb643829.aspx

    -B

  • Amazing videos beth.  Excellent job

    Could you create more videos on vb 2005 besides VB 2008?  

    Actually, there are some important topics in database you haven't discussed.

    For example, how to export data in datagridview to excel or word by click a button.

    others are how to import/export data from text file and how to transfer data between two tables in a database which are different in the number of columns of both but with the same data type.

    I hope you create at least a basic technic.

    BTW, your videos are still the best. keep moving

  • Hi khun,

    All the forms over data (http://msdn2.microsoft.com/en-us/vbasic/bb466226.aspx#formsoverdata), object binding (http://msdn2.microsoft.com/en-us/vbasic/bb466226.aspx#objectbinding) and interop videos (http://msdn2.microsoft.com/en-us/vbasic/bb466226.aspx#interop) were done with VS2005. Only the LINQ videos are VS2008 specific.

    If you are looking for more SQL videos, check these out: http://www.asp.net/learn/sql-videos/

    And I do plan on doing more with data :-). Thanks for the feedback!

  • Hi Beth,

    I must say I have learned so much from your videos. I have been following along while using your examples to create my own application. I have created a database, dataset, table adapter, binding source, and a binding navigator. I also made use of the error provider and everything works great. What could be done to keep the user form trying to add or navigate away from a record that does not meet the business rules? When the user presses any buttons on the binding navigator it of course generates an error. Tryig to disable the buttons does not work. Could this possibly be a new video...Advanced Error Handling?

    Great Videos,

    Randy  

  • Hi Randy,

    You can actually override the behavior of the buttons on the BindingNavigator to check for the DataSet.HasErrors property before allowing the add. In the property sheet for the BindingNavigator set the AddNewItem property to None and then double-click on the add button and write code like:

    Me.MyBindingSource.EndEdit()

    If Not Me.MyDataSet.HasErrors Then

       Me.MyBindingSource.AddNew()

    End If

    HTH,

    -B

Page 3 of 6 (90 items) 12345»