Adding Button Controls in VB Database 2010,use buttons to control database in vb2010,database control in vb2010
Hello everyone, I hope you all are fine and having fun. In today's tutorial, we are gonna have a look at How to add Button Control in VB database 2010. I have posted the first part of this tutorial few days ago in which I have shown that How to Create a Database in Microsoft Visual basic 2010. If you have missed that part then you can't understand the today's lecture. Today we will continue with the same application which we created in the last part and will add few new features in it. Creating database is difficult but adding features in it is very easy job and its also a must requirement of the application because user wants an easy control of application. So in order to make the application user friendly its necessary to add few features in it. In the next post, I have discussed How to Update Database Table with Programming in VB 2010. I have divided this project or tutorial into few parts, as covering the whole database topic in one tutorial is not possible. If any of you have any problem in any part,ask in comments. So let's get started with Button Control in VB Database.
  • In the last part of this tutorial, we have created a database application shown in the below figure:
  • In today's lecture we will add few new features in the above application and at the end of today's lecture, the above application will looks like this.
  • You can see in the below figure that now we have Button Control in VB Database.

Step 1 : Add, Save & Remove Buttons

  • First of all open the application which we created in the previous part of this tutorial.
  • Now add three buttons on it as shown in the below figure :
  •  Now click the button 1 and change its name from properties to Add, button 2 to Save and button 3 to Remove as shown in figure below.
  •  We have added buttons and also changed their names according to our requirement, now we are gonna add functionality in these buttons i.e. what function they perform when someone click them.
  • Double click Add button and put this code in its function.
 Try Me.Contact_FormBindingSource.AddNew() Catch ex As Exception End Try
  • Now double click Save button and add this code in its function.
  Try Me.ValidateChildren() Me.Contact_FormBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.ContactsDataSet) Catch ex As Exception End Try
  • Now double click the Remove button and add the following code in its function.
Try Me.Contact_FormBindingSource.RemoveCurrent() Catch ex As Exception End Try
  • Now run your application and if everything's fine then when you click Add button, a new line will appear in the database where you can enter the next contact. After adding the contact, when you click on the Save button software will automatically save the contact in database and if you click the Remove button then the selected entry in database will be deleted.

Step 2 : Next & Previous Buttons

  • Now add two more buttons from toolbar, just under these three buttons as shown in the figure below:
  • Change their names to Previous and Next as shown in image below:
  • Now double click the Previous button and add the below code in it.
  • After that double click the Next button and add the below code in its function.
  • Now run your application and when you click the Next button the selection in database will move downward i.e towards the next entry and when you press previous it will move upward i.e towards the previous entry.

Step 3 : Move To Top & Move To End Buttons

  • Now again add two more buttons as shown in the figure below:
  •  Remove Button1 to Move To End and Button2 to Move To Top as shown in below figure:
  •  Now double click on Move To End Button and insert the below code in it.
  • After that double click on Move To Top button and add the below code in its function.
  • Now run your application, and check the working of these two buttons. When you click Move To Top button the database will rolled up and you will reached the first line and vice versa for second button.
Okay friends that's all about Button control in VB Database, and I really got tired. Level of today's post is intermediate but its really important as in the next chapter of this tutorial we are gonna move into pro level so if you don't practice it you wont get the next chapter. Okay I gotta go. Stay Blessed. Take care. Note :
  •  This software along with code has already been emailed to all the subscribed members. If someone didn't received it then post your email in the comments and i will send it to you.
  • if someone wants this software along with the code then subscribe to our email newsletter and it will be automatically emailed to you.