Visual Basic database programming with SQL Server by example

Learn how to write to SQL Server using T-SQL commands from Visual Basic by developing a real life example application.
4.3 (4 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
27 students enrolled
Instructed by Neil Waring IT & Software / Other
52% off
Take This Course
  • Lectures 48
  • Length 3.5 hours
  • Skill Level Intermediate Level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works


Find online courses made by experts from around the world.


Take your courses with you and learn anywhere, anytime.


Learn and practice real-world skills and achieve your goals.

About This Course

Published 9/2016 English

Course Description

Learn how to create SQL Server databases and tables and create, update and read records directly from a Visual Basic project by building an example application from scratch.

.Net SQL Server developers are always in demand. Build a strong foundation in Visual Basic programming with SQL Server databases with this course.

Watch me create the application from scratch and code along with me.

Source code available for download.

This course is project based and you will build an example Helpdesk application by creating forms and writing code in Visual Basic and creating a database and tables in SQL Server Express using SQL Server Management Studio.

You Will Learn How To

  • Install SQL Server Express

  • Install Visual Studio Express

  • Create a Visual Basic project in Visual Studio

  • Create a SQL Server database in SQL Server Management Studio

  • Connect to the database in Visual Basic

  • Create tables in SQL Server

  • Create primary keys

  • Create forms in VB to add and update records

  • Add records to  SQL Server database from Visual Basic

  • Update records in  SQL Server database from Visual Basic

  • Use parameters to pass user data to SQL Server

  • Validate user data in Visual Basic

  • Handle errors in Visual Basic

  • Delete command in SQL Server

  • Display records from SQL Server in Visual Basic

  • Using one to many relationship in tables

  • Use SQL DISTINCT and MAX keywords in Visual Basic

  • Use SQL joins for returning records from linked tables

  • Create multipurpose forms in Visual Basic

  • Share code using modules in Visual Basic

No Risk – Money-Back Guarantee

Once you purchase the course, if for any reason you are not satisfied with the course, Udemy offers a 30-day money back guarantee.

What are the requirements?

  • You should be familiar with simple programming concepts, eg. variables loops etc. Some exposure to Visual Studio would be helpful, but not required.

What am I going to get from this course?

  • Build applications in Visual Basic to display,create and update records in SQL Server

What is the target audience?

  • Visual Basic/Visual Studio programmers who want to work with SQL Server

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.


Section 1: Welcome

A few words to describe the course, what we are going to learn, and some advice regarding how to get the most from the course. 


Downloading and installing SQL Server Express, walking through the various configuration screens. 

Downloading and installing Visual Studio Express which is very straight forward.

Section 2: Creating a database and connecting to it from Visual Studio

We'll go into SQL Server Management Studio and create the database we will use in our application.


We create a project in Visual Studio, add a button to a form and write code to build a connection string and connect to the database we created earlier.

Section 3: Adding people records to the system

Back into SQL Server Management Studio where we will create a table in our HelpDesk database to hold people details.


In Visual Studio we create a new form in our project and add controls to it for entering people details.


In this lecture we create a module in our project and learn how to share global variables and create routines that can be called from anywhere in the project


We learn how to create a query in SQL Server Management Studio to insert records into our people table.


In our project we learn how to pass an insert command to SQL Server directly from code connected to a button on a form, and to get back from SQL how many records were inserted.


In this lecture we take data entered into the form to use in the insert command. For safety we learn how to use parameters to pass the entered data to SQL Server.


We can now add records into our database from a form. In this lecture we make sure that data has been entered into the form before we try to add a record.


In this lecture we add error handling code around our insert statement, we need this for those (hopefully) rare occasions when we can't write the record, eg. we've lost connection to the server, or to the network. Rather than the program just crashing we need to deal with errors gracefully.


Now we have some people records in our table we want to return a list of departments from our people table, with each department only appearing once in the list. We go into Management Studio to see how we can do this.


We query SQL Server directly from code in our project to build a dropdown list of departments.


We query SQL Server directly from code in our project to display users on the main form.


The project loads our main form on startup so we add a right-click context menu to link to our people form

3 questions

Check your understanding so far

Section 4: Updating people records

We now want to allow people records to be updated, but rather than create a new form we'll utilise the add people form by adding code to enable it to have different functionality depending on whether we want to add a new record or update an existing record


We learn about the SQL update command in Management Studio.


In this lecture we create the code for updating records from Visual Studio


This is a brief discussion around SQL update and delete commands and how easy it is to do the wrong thing !

3 questions

Check your understanding

Section 5: Adding task records

We go into SQL Server Management Studio and create a table to hold task records


We create a form for entering task information in Visual Studio


In our Add task form we need to show a list of people to be able to select who has reported the task


We don't want to show technicians in the list of people so we need to add another parameter to our code for loading people.




We use the SQL MAX command from Visual Studio code


How to call SQL insert command from Visual Basic


In this lecture we look at a different method for validating user input

3 questions

Check your understanding

Section 6: Displaying tasks on the main form

We now have tasks and people so we need to add another tab on our main form


Our people and task tables are related by the peopleid. In SQL Management Studio we build a query to return data from linked tables using SQL Join


In our project we run the Join command to return a list of tasks with people names

3 questions

Check your understanding

Section 7: Assigning tasks to technicians

In this lecture we create a new form to allow tasks to be assigned to technicians


In this lecture we display task data on the Assign form by accessing the main form from the Assign form


We want to display technicians only on the Assign form so we extend the versatility of some of our shared code even further


In this lecture we update the task record with the technician id


We now have two columns in the task table that relate to different records in the people table. We change our select statement for displaying tasks to now have two joins between the task table and people table.


We update our task display to show the name of the person reporting the task and the name of the technician the task is assigned to.

3 questions

Check your understanding

Section 8: Adding actions to tasks

We are going to record actions against tasks. There may be several actions for tasks so we create the Actions table to allow for this. This is a 'one to many' scenario. 


We need a form to allow the entry of actions, so we extend the logic in the Assign form to handle both assigning tasks and adding actions to tasks


In this lecture we insert records into the actions table


In this lecture we continue to extend the functionality of the Assign form by displaying existing actions for a task when adding an action

Section 9: Closing tasks

We now add the ability to close tasks by further extending the functionality of the Assign form to allow the status of a task to be set to Closed


We now have open and closed tasks. We add more context menu options to show All tasks, Closed tasks or Open tasks. We change the code for loading tasks to dynamically build a Where clause for a Select statement depending on which menu option has been chosen


In this lecture we add a create date column and a close date column to the task table and change the insert and update code to put data into these columns


In this lecture we add code to make sure that operations are carried out in a prescribed order, eg a task cannot have actions added if it has not been assigned


In this lecture I explain why there is no delete task option, and discuss consideratons for archiving tasks


In this lecture I discuss a couple of alternative options for generating sequential numbers for records

2 questions

Check your understanding

Section 10: Final words

Some final thoughts and a downloadable copy of the project

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Neil Waring, Systems Architect and Developer

Hello there, I’m Neil Waring and I have been working in software and systems development for over 30 years.

I have worked for a number of UK companies in that time, in various industries and using various technologies.

My career began with a training course in Cobol, and since then I have learnt to develop in Assembler, DataBasic,  Microsoft Basic, Visual Basic, Delphi, Asp.Net, HTML, CSS, JQuery and PHP.

I spent 15 years as the IT Manager of a multi million pound turnover business where, as the leader of a very small team, I developed and designed a  bespoke system written in Visual Basic and running on Microsoft SQL Server. I have spent the last couple of years being the designer and only developer of a system for a UK financial services company.

Throughout my career I have been constantly learning as technology has changed so much over that time. From desktop development to web development, even though there is a wealth of material available now, I always prefer training that shows how to use development tools to make real world applications.

I am now focussed on passing on the experience and skills I have acquired by producing project based training courses that teach how to build real world applications.

Ready to start learning?
Take This Course