How to Add New Data Source

One of the coolest features of Visual Studio .NET is the ability to bind a database into Windows Forms easily using DataSet. Since VB 6.0, I’m waiting for this kind of feature to be implemented in VB.NET. I am used with MS Access before and seem that VB.NET and MS Access has no difference when it comes to DataBinding.

There are many ways to bind your data. You can use the old fashion which is hard-coding, but this is out the scope of this tutorial. Why use hard-coding if you can do it easily using drag and drop operation?

Unless otherwise it is necessary, you are free to use code in your program to manipulate the data. But this tutorial will focus more on Strongly Type DataSet. The point here is to avoid errors in your code.

IntelliSense is design to make coding easier and faster and Strongly Type DataSet is included here.

Now, let’s add a DataSet.

  1. Click on data sources.
  2. Add aew data source.
  3. Select databse.
  4. Click Next.

    Add a DataSet

Choose Your Data Source

  1. Click New Connection.
  2. Select server name.
  3. Select database name.
  4. Click OK.

    Data Connection

  5. Click Next.

    Data Connection 2

  6. Leave the default value and click Next.

    Connection String

  7. Expand the Table node and select “Books”. We will add a new dataset on each of the table that represents as masterfiles. Change the DataSet name to “BooksDataSet”.

    Choose Database Objects

  8. Repeat the step by adding Course, Members, and Subject tables. Name the DataSet based on the table name. Example: Books is named as “BooksDataSet”. So the DataSet of Members table is “MembersDataSet”. Follow Course and Subject also.
  9. When you click the Finish button you will see a BooksDataSet under Data Sources. Click Add new data source to add more dataset for Members, Course and Subject tables.

    Add New Data Source

Note: You DO NOT need to create new connection when you add another DataSet since it is already set when you create a DataSet for your Books table.

Here’s the DataSet for our four (4) masterfiles.

Data Sources

Now, let’s create DataSet for Borrow and Return tables. These two tables must be treated differently since they have relation to another table.

Click add new data source and on the “Choose Your Database Objects” Select Borrow and BorrowDetails.

BorrowDataSet

Do the same with Return and ReturnDetails.

ReturnDataSet

Here’s our final data source.

Final Data Source

The steps above are so simple but it may become difficult for you if you will not follow it step by step.

Out next topic will focus on How to Add Windows Forms.

Back to Visual Basic .NET 2008 Tutorial.

Comments

Dear Sir, I have followed the steps you have given here but when I tried to use Datasource to put an sql file on to the application I received error message "I have no permission to open the file". Can you help me please. [email protected]

Add new comment