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.
Choose Your Data Source
- Click New Connection.
- Select server name.
- Select database name.
- Click OK.
- Click Next.
- Leave the default value and click Next.
- 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”.
- 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.
- 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.
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.
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.
Do the same with Return and ReturnDetails.
Here’s our 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
Add new comment
- Add new comment
- 140 views