Lesson 34: Database Introduction in VB2019
Learn database fundamentals and how to create database applications with ADO.NET
Key Takeaway
Understand database fundamentals and learn to create powerful database applications in VB2019 using ADO.NET and SQL Server.
In this lesson, we transition from graphics and animation to database programming - a critical skill for building data-driven applications. Databases allow you to store, retrieve, and manipulate large amounts of information efficiently.
Database Fundamentals
Learn core concepts of databases and their importance
SQL Server
Work with Microsoft SQL Server for robust data management
ADO.NET
Connect applications to databases using ADO.NET
Data Management
Create applications that store, retrieve and edit data
34.1 Introduction to Databases
In the past, people managed data manually using cards and folders. In today's digital age, computer-based database management systems handle data faster and more efficiently than manual methods. With network and Internet technologies, data can now be managed both locally and remotely.
Database management systems are essential for running:
- Payroll systems
- Inventory systems
- Accounting systems
- Payment systems
- Order handling systems
- Customer relationship management (CRM) systems
Popular commercial database management systems include:
DBMS | Description | Use Cases |
---|---|---|
Oracle | Enterprise-grade relational database | Large corporations, complex systems |
Microsoft SQL Server | Relational database management system | Business applications, web applications |
Microsoft Access | Desktop database management system | Small business applications, personal use |
MySQL | Open-source relational database | Web applications, small to medium businesses |
34.2 Creating a Database Application
A database management system deals with storing, modifying, and extracting information from a database. While DBMS can be complex for non-technical users, we can create user-friendly database applications in VB2019 that handle these tasks with the DBMS running in the background.
Visual Basic 2019 uses ADO.NET to handle databases. ADO.NET works with advanced database management systems like Microsoft SQL Server.
Database Application Components
To build database applications in VB2019, we use several ADO.NET objects:
Object | Description | Namespace |
---|---|---|
SqlConnection | Connects to a data source in SQL Server | System.Data.SqlClient |
DataTable | Stores data for navigation and manipulation | System.Data |
DataAdapter | Populates a DataReader and updates data | System.Data.Common |
These objects belong to the System.Data and System.Xml namespaces, so we need to reference them before we can use them.
Referencing ADO.NET Objects
- Choose Project > Database Project Properties
- Click the References tab
- Under imported namespaces, ensure System.Data and System.Data.SqlClient are selected
- Click Save All and return to the IDE

Figure 34.1: Adding required references
' Import required namespaces Imports System.Data Imports System.Data.SqlClient Public Class Form1 Dim connectionString As String = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;" Dim connection As New SqlConnection(connectionString) Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try connection.Open() MessageBox.Show("Connection successful!") Catch ex As Exception MessageBox.Show("Connection failed: " & ex.Message) Finally If connection.State = ConnectionState.Open Then connection.Close() End If End Try End Sub End Class
Sample Contacts Table
ID | Name | Phone | |
---|---|---|---|
1 | John Smith | [email protected] | (555) 123-4567 |
2 | Sarah Johnson | [email protected] | (555) 987-6543 |
3 | Michael Brown | [email protected] | (555) 456-7890 |
4 | Emily Davis | [email protected] | (555) 234-5678 |
Figure 34.2: Sample database table structure
Setting Up SQL Server
To follow along with this lesson, you'll need Microsoft SQL Server installed. You can download the free Express edition:
Download SQL Server Express
Visit the official Microsoft website to download SQL Server 2019 Express:
Download SQL Server ExpressThe Express edition is free and includes all the core database features needed for learning and development.
Lesson Summary
In this lesson, you've learned the fundamentals of databases and how to prepare for database programming in VB2019:
Database Concepts
Understand the role of databases in modern applications
ADO.NET Components
SqlConnection, DataTable, and DataAdapter objects
Namespace References
Importing System.Data and System.Data.SqlClient
SQL Server Setup
Downloading and installing SQL Server Express
In the next lesson, we'll create a connection to a database source file and start working with real data.
Next Lesson
Learn to connect to databases in Lesson 35: Connecting to Databases.
Related Resources

Visual Basic 2019 Made Easy
Master Visual Basic 2019 with this comprehensive guide that includes detailed coverage of database programming techniques. Learn to create professional database applications.
Key Database Topics:
- Database fundamentals and concepts
- SQL Server setup and configuration
- ADO.NET programming techniques
- Data binding and manipulation
- Practical database projects with source code

Database Programming with VB.NET
This comprehensive guide focuses specifically on database programming techniques in VB.NET, covering everything from basic concepts to advanced techniques.
Database Coverage:
- In-depth ADO.NET coverage
- SQL Server integration
- Entity Framework
- Real-world database application examples