Sharing the goodness…
Beth Massi is a Senior Program Manager on the Visual Studio team at Microsoft and a community champion for business application developers. Learn more about Beth.
More videos »
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.
You'll probably be much better off creating a search form that pulls up a set of data and then opens the edit form for just that small set. That way you can still use the navigation buttons. Otherwise your search form can pull up the single row the user is interested in and you can remove the navigation all together. It's not very scalable to query the database the way you're doing it because you are making a connection each time which is expensive. (You really need to balance the number of connections with the size of the data returned.) The previous, next, etc. buttons are meant for navigation of the rows you have already in your dataset on the client.
Thanks, Beth. You rock.
I have an invoice tab in my form so when the user clicks on the invoice tab, then i load the invoices for that current customer there. connection cost is less expensive now.
Beth, there should have been something of this quality around long ago. Lots of people learn well through this format. Thanks to you and Microsoft for making this available.
Classes (objects) are very useful. Perhaps a series could be produced to cover the basics here. By the way, the short series you have started on objects jumped right into hooking the (data) objects right to the form. I didn't catch anything about how these are created in the first place, i.e., the .DLL file.
I have a question regarding an update store procedure.
I set this store procedure as the store procedure for my tableAdapter and mapped the appropriate column names like you did in the videos for the parameter collection.
I have a masked textbox for a telephone number. This textbox is generated from on of the columns in the table.
Now how do tell the update store procedure to grab the unmasked value from the textbox instead of its masked text. I want to parse the textbox to pass 7149999999 to the update store procedure instead of (714) 999-9999. The reason i want to do this is because i want the users to see the more readable masked phone number in the textbox but when i store it i only want to store the numbers only.
First I want to say that I really enjoyed watching your videos and I learned a lot from them.
Now to business :)
I have trouble with an application I am writing. I want to default the value for a new item in a table to be the same value from the item in the previous row(same column).
For example if on previous row the user entered in column location for example "Mars" I want on the new row the default value to be "Mars" in location. I need this on a few forms I am designing.
I am using vb 2005 + sql serv 2005
Thank you in advance for any future input.
I'm anctiously waiting for a response. :)
You can use code like this to get the previous row:
If Me.MyBindingSource.Position > 0 Then
Dim prevRow As MyDataSet.MyRow = CType(CType(Me.MyBindingSource.List(Me.MyBindingSource.Position - 1), DataRowView).Row, MyDataSet.MyRow)
Take a look at this video to understand databinding better and how to work with data in your code: http://msdn2.microsoft.com/en-us/vbasic/bb725824.aspx
Also you'll probably want to try asking questions in the VB forums as you'll probably get much more rapid responses :-)
I tried your method and I customized it to what I need including some enhancements and it worked like a charm. Thanks Beth.
I review the objects in the first part of the video. The classes are City and State that just have a few properties. You can download the code here: http://blogs.msdn.com/bethmassi/attachment/3535373.ashx
Awesome series of videos. I have learnt more from watching your video's than i have from the last two VB books i have read. Please make more!!
Your example for checking last name has helped me cover off most of my validation issues however i am having trouble with checking if a cell is unique.
I reviewed this msdn walkthrough (http://msdn2.microsoft.com/en-us/library/t4a23xx4(VS.80).aspx) but the code logic is in the main form and i really want the logic in the dataset (as you say it's best practice! :) ). I also note the MSDN example isn't really verifying the column entry is unique...its just assuming it is.
Basically, i want to do the same sort of subroutine validation you showed in your demo with the columnerror set if the row is not unique. Could you provide me an example?
Spectacular job you made with these videos (clear, clean, neat and to the point)
You made my YEAR with this! Thank you very much!
I am struggling to find a good source on how to work with security...
I wish you could give me advice on where to find a good source for it.
Just to narrow my question about "a good source on how to work with security..." I am referring to Windows Forms and SQL Server 2005 (client-sever apps).
Thanks in advance
You can use a DataView to check if there is an existing row that contains a specific value by setting the Filter property. From the RowChanging event (off the top of my head):
Dim dv As New DataView(Me) 'Me is the DataTable
dv.RowStateFilter = CurrentRows
dv.RowFilter = "MyField = '" & value & "'"
If dv.Count > 0 Then
' Column value is not unique
Check out the SQL Server Security Center: http://www.microsoft.com/sql/technologies/security/default.mspx
Here are some links to some good WhitePapers too:http://www.microsoft.com/sql/technologies/security/whitepapers.mspx
I am trying to learn VB and then I found your videos and I though it was going to be very easy to learn this way.. but I am following the first example and the changes I make in the form doesnt' update in the table! I am not using any store procedure .. so I don't know what's going on.. PLEASE HELP...!! Ihave 3 months to finish a proyect and I can't even save changes in a simple table...