1. Technology

Data Sources, VB.NET, and SQL Server

They're a fast way to get the job done!


Updated June 30, 2014

This article, the seventh in this series for beginning database programmers, is about Data Sources, VB.NET, and SQL Server. In a way, it's a return to the first article in the series. The goal of the first article was to demonstrate how fast and easy it could be to code a complete SQL Server based application. Programmers often think that databases are "too hard" so they have to use a simple file. The goal of part one of this series is to convince you that you can use a real database for just about any data need.

The way the first article accomplished that was to use the latest databound tools available in VB.NET, Visual Studio, and SQL Server. These tools do nearly all of the work for you. The completed application in that article only used a couple of lines of VB Code.

After that, however, the series went back to basics. The problem with high-level tools like the ones we used in the first article is that you don't get a real understanding of what's actually happening behind the scenes. So we developed a simple application using more "direct to database" methods with the goal of creating that understanding. As you become more familiar with databases and VB.NET, you'll discover that there are situations where you have to use the direct methods anyway.

In this installment of the series, we return to the high level tools and show how they accomplish the same goals (and more) with far less effort. But since completely new objects and concepts are used, most of the article concentrates on explaining them. The application that is developed has all of the CRUD features (Create, Read, Update, Delete) because these features just happen automatically when you use these high-level tools. But the result isn't as customized for the same reason. When you use automated features, everything starts to look the same.

You might want to review the previous article, Coding the VB.NET Many-to-Many Database App, to see how it was done there before moving on to this one.

Using a data source (rather than coding directly against the database) can be a new concept especially if you have written a lot of code that uses direct files. You might think of it as being something like a person who suddenly comes into wealth and hires a butler and a maid to do everything. Instead of going into the kitchen and making your own cup of coffee, someone brings it to you. It takes some getting used to.

To make this as clear as possible, we're going to build an app from scratch so that all of the steps involved are part of the process. We will use the same "many to many" database from the previous article, however.

Microsoft defines a data source this way:

"Data sources represent the data available to your application. More specifically, data sources represent the data that you want to work with in your application. Data sources can be obtained from databases (including local database files), services, and objects."

Like a lot of Microsoft documentation, this one is so general that it really doesn't help a lot. So let's see what it looks like in code. The first step is to create the Data Source itself. We do just that on the next page.

  1. About.com
  2. Technology
  3. Visual Basic
  4. Using VB.NET
  5. A Visual Basic Database Course for Beginners (VB.NET)

©2014 About.com. All rights reserved.