Library tutorials & articles
An Introduction to VB.NET and Database Programming
- Introduction
- Where to Begin
- The Recipe Application
- Data Binding
- Finishing Up
The Recipe Application
The Murach book showed me how to create a Connection, Data Adapter, and a Dataset in Chapter 17. In Chapter 18 it discussed how to bind controls to the data and then use bound controls to update, add, and delete data rows. Parameterized queries tied everything together for the Recipe Application. As you can see below I have created two DataAdapters and a Dataset for each. I need to keep the Category table and the Recipe Table separate. There may be a better way to do this, but this worked.
One of the most important things I learned from the book is that you must fill the dataset. With VB.NET you are not working directly with the data like you would using MS Access. You are working with a 'picture' of the data created by your SQL statements in the Data Adapter and then filled into the Dataset. You can load the data in any event of the form - a button click, a combo box selection or a form load event. In most cases you will load the data in the form load as seen below.
Private Sub Form1_Load( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DaCategory.Fill(DsCategories1)
DaRecipes.Fill(DsRecipes1)
Me .SetEntryControls( False )
Me .SetMaintenanceButtons( True )
RecipesBindingManager = Me .BindingContext(DsRecipes1, "Recipes" )
btnEdit.Enabled = False
lblCategoryText.Visible = False
txtCategory.Visible = False
End Sub
The important lines in filling the data are the two listed in red. The other line that was critical to using the combo box to navigate records was the line in green. The binding manager tracks the position or row of data that the application is currently viewing or potentially editing. You should also notice the Me.SetEntryControls(False) line of code. This is calling another sub routine that sets the enabled or disabled status of certain controls on the form. Each control could be listed individually, but if you have several controls that are always going to be enabled or disabled as a group then making a separate sub for that update will make it easier for you to enable and disable them throughout your application.
Private Sub SetComboBoxControls( ByVal bComboMode As Boolean )
cboCategory.Enabled = bComboMode
cboRecipe.Enabled = bComboMode
End Sub
Related articles
Related discussion
-
How to write the category attribut in a class dynamically
by converter2009 (1 replies)
-
VB.NET: Hide and show table using radio buttons
by converter2009 (1 replies)
-
VB.Net Button Problem
by pysdex (0 replies)
-
Unable to access AxInterop.AcoPdflib.dll on 64 bit OS
by Shaila14041981 (0 replies)
-
Very Urgent regarding deleting the images from a folder
by Nanosteps (6 replies)
Related podcasts
-
xpert to Expert: Inside Concurrent Basic (CB)
"Concurrent Basic extends Visual Basic with stylish asynchronous concurrency constructs derived from the join calculus. Our design advances earlier MSRC work on Polyphonic C#, Comega and the Joins Library. Unlike its C# based predecessors, CB adopts a simple event-like syntax familiar to VB progr...
Hi Chathura,
Good day to you. As you asked the question about the vb.net. And from your explanation you also said that you are little good in vb6. So once you are entering the .net framework area you should be aware of this area. Anyway you are a new user of this programming even u are good in vb6. The main matter in vb.net is that, its quit similar like java. Where in java, you write program in one platform but you can run the program from all other platform. But in vb.net you write the program in all platform but run the program from one platform. Mostly we use vb.net for database connectivity application. We choose this also for web applications. So its very usual that to make a program in vb.net we will be using SQL access, ado.net or asp.net etc. So its natural that if you download vb.net the other software also included with it. May I know what site you used to download vb.net? May be you are downloading fro, any wrong sites. Thank you.
Best regards
Imran
i want to how to have a data set of more than10 tables
Hi,
As a M.E. student of Computer Engineering i am serching for the VB.net Platfrom how 2 start with & find your para usefull. Thanks
Hi All
I'm a beginner to VB .NET but have quite good knowledge in VB 6. I'm currently in the process of switching to .net.
When I install visual studio 2005, there are SQL Server Mobile package and some other SQL server stuff. could you please tell me why they are there and what I can do with them?
Also, is there one called profile or something? As I heard, as a VB 6 project can hold many forms, in .Net there are profiles which can hold many projects. Could you please explain?
Appreciate your help
Best Regards,
Chathura
Hi,
I am having a problem in data binding in vb.net. I have to use MS-Access as database and win forms controls to design a application. Please guide me . Specially in adding the records into the table at run time. Like I just enter the data in the text boxes and clike on the ADD button. The data should automatically be added into the table.
Thank you.
a web site that I wrote works well under internet explorer, but when I run the site on mazilla the forms get changed.
The colors are deleted, and the sizes of the textbox's, change. When I examined the html code generated, there was a difference between the code for IE and Mazilla. How do I correct this
Hi,
I have a bit understanding of VB.net.
Currently I m using winXP Pro.
I Create an Installation, and I set
DetectNewerInstalledVersion to False
RemovePreviousVersions to True.
However, When I first install a fresh copy, it run fine. An entry was created on Add/Remove Program.
After I update something on the application and rebuild the installation file and change the product code and upgrade code; I re-run the installation again without uninstall the previous version.
Installation was success. But the problem is it create 2 entry in Add/Remove Program.
If i install 5 time, it will create 5 entry.
I'm not sure what's wrong with my installation scripts.
Like Winzip or Winrar. no matter how many time we run the installation, it only create one entry on Add/REmove program.
Is there any other way to fix this ?
Please help!
Hi,
The topic which you have explained in the article has been of much help to me,I have Joined an organisation as a programmer.As of now,i have not yet started woith programming.
But since i am new to this field,i would expect you to kindly post more articles which would make working with databases easy.
Regards,
Anu
Chas,
VB .NET is the Visual Basic language which you can purchase by its self. .NET Studio is the development Suite which can contain several different development languages, such as VB, C#, Visual J, etc. I think you can get VB .Net for like $150 and the .Net Suite is around $1000.
If you are a college student you can either of these at a greatly reduced rate for the academic version.
Chester
However, if you purchase VB.NET Professional, that will basically be Visual Studio with support for VB.NET (and not C#)
I wanted to ask you, what's the difference between Visual Basic.NET and Visual Studio.NET
I know a litlle about Visual Basic 6 but I just got a new job and want to learn more stuff so that
I can create a nice program for my company.
I will purchase the books you recommend for beginners. thanks
This thread is for discussions of An Introduction to VB.NET and Database Programming.